I have recently started working on qiskit and I am struggling to use qc.initialize
API in any practical or useful application. I have read at multiple places that they are used to feed data to the quantum circuits.
For developing an understanding of the quantum computers, I executed the code of Bernstein Vazirani Algorithm(secret number detector) on qasm_simulator using Pycharm IDE as shown below without using any initialization circuit.
import qiskit
from qiskit import IBMQ
import time
from qiskit import *
from qiskit.tools.visualization import plot_histogram
from qiskit.tools.visualization import plot_bloch_multivector
import matplotlib.pyplot as plt
from qiskit.tools.monitor import job_monitor
#IBMQ.save_account('Account key',overwrite=True) # Run it for once
# 6 bit secret number
secretNumber= '101001'
circuit= QuantumCircuit(6+1,6) # 6 qubit for secret no. +1 qubit
circuit. h([0,1,2,3,4,5])
circuit.x(6)
circuit.h(6)
circuit.barrier()
# splitting the string into char
splitSecretNumber= list(secretNumber)
lengthofSecretNumber= len(splitSecretNumber)
x=0
while(x< lengthofSecretNumber):
if(str(splitSecretNumber[x])=='1'):
circuit.cx(int(x),6)
x=x+1
circuit.barrier()
circuit.h([0,1,2,3,4,5])
circuit.barrier()
circuit.measure([0,1,2,3,4,5],[0,1,2,3,4,5])
circuit.draw(output="mpl")
simulator= Aer.get_backend('qasm_simulator')
simulationResult = execute(circuit,simulator, shots=1).result()
counts= simulationResult.get_counts()
print(counts)
plot_histogram(simulationResult.get_counts(circuit))
plt.show()
Please guide me to convert this code to take Input data using initialization circuit. Also, please suggest me some good papers to read on initialization. Thanks in advance.