qit.examples.bernstein_vazirani¶
- qit.examples.bernstein_vazirani(n=6, linear=True)¶
Bernstein-Vazirani algorithm demo.
Simulates the Bernstein-Vazirani algorithm [2], which, given a black box oracle implementing a linear Boolean function
, returns the bit vector a (and thus identifies the function) with just a single oracle call. If the oracle function is not linear, the algorithm will fail.- Parameters
n (int) – number of qubits
linear (bool) – if False, use a random nonlinear function instead, leading to the algorithm failing