# -------- Main Body ----------------------------------------------------------------------- pstep = 0 ret = 'y' while ret == 'y': pstep += 1 c = Circuit(N) qcam.propinit(N, c, initial_a) for i in range(pstep): qproc() master_a = np.array(c.run()) num, vector_a, prob_a = qcam.qvextract(N, R, 1, master_a) stdev, probability_a = qcam.qcalcd(N, num, vector_a, prob_a) qcam.qcresultout(N, pstep, num, initial_a, vector_a, prob_a, stdev, probability_a) stepdist_a[pstep, 0:N] = probability_a[0:N] marking_prob_a[pstep] = prob_a[35] * 100 #Decimal number of marked vector stdev_a[pstep] = stdev ret = input(' NEXT(Y/N)?') qcam.qcfinal(N, pstep, initial_a, stepdist_a, stdev_a) fout(pstep, initial_a, marking_prob_a) qcam.qcamplot(N, pstep, stepdist_a)
from blueqat import Circuit import numpy as np import qcam # -------- Setting ------------------------------------------------------------------ N = 8 # number of cells :You can change. R = 1 # number of registries initial_a = np.array( [0.9, 0, 0, 1, 0, 0.6, 0, 0], dtype='float') # initial probability distribution :You can change. vector_a = np.array([[0] * N] * (2 ^ N), dtype='int') csum_a = np.array([[0] * N] * (2 ^ N), dtype='float') final_a = np.array([0] * N, dtype='float') #---------- Main Body ---------------------------------------------------------------- ret = 'y' while ret == 'y': c = Circuit(N) qcam.propinit(N, c, initial_a) master_a = np.array(c.run()) num, vector_a, prob_a = qcam.qvextract(N, R, 1, master_a) stdev, final_a = qcam.qcalcd(N, num, vector_a, prob_a) qcam.qcresultout(N, 0, num, initial_a, vector_a, prob_a, stdev, final_a) ret = input(' NEXT(Y/N)?')