/** @file * Implements the Bernstien--Vazirani circuit * * @author Tyson Jones */ # include # include # include # include # include "QuEST.h" void applyOracle(Qureg qureg, int numQubits, int secret) { int bits = secret; for (int q=1; q = |s>|1> int ind = 2*secret + 1; qreal prob = getProbAmp(qureg, ind); printf("success probability: " REAL_QASM_FORMAT " \n", prob); } void applyBernsteinVazirani(Qureg qureg, int numQubits, int secret) { // start in |0> initZeroState(qureg); // NOT the ancilla pauliX(qureg, 0); // H all qubits, including the ancilla for (int q=0; q state Qureg qureg = createQureg(numQubits, env); // search for s using BV's algorithm applyBernsteinVazirani(qureg, numQubits, secret); // tidy up destroyQureg(qureg, env); destroyQuESTEnv(env); return 0; }