quantum_circuit::initialise()← Back to Class quantum_circuit
Set amplitudes of the state. This function takes care of normalisation so you don't have to do it yourself
quantum_circuit::initialise(amplitudes)
amplitudes (array) — The array of amplitudes. The array size must be \(2^N\), where \(N\) is the total qubits of the circuit
quantum_circuit — Returns the instance of class quantum_circuit
import quantum
qc = quantum_circuit(2)
data = [0.5, 0.5, 0, 0]
qc.initialise(data)
qc.print_statevector()
' Output:
' [ 0.707107 + 0i
' 0.707107 + 0i
' 0 + 0i
' 0 + 0i ]