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