qrisp.QuantumArray.init_state#
- QuantumArray.init_state(tuple_list)[source]#
Method to initiate arbitrary quantum states in this array. The semantics are similar to the
QuantumVariable equivalent
of this method.The given state will be normalized.
- Parameters:
- tuple_listlist of tuples
The list of tuples describing the quantum state. The first componenet of the tuples needs to represent the array and the second the required amplitude.
- Raises:
- Exception
Tried to initialize quantum state on qubits which are not fresh anymore.
Examples
We initiate a quantum state on an array and evaluate the measurement probabilities.
>>> from qrisp import QuantumArray, QuantumFloat >>> qtype = QuantumFloat(3) >>> q_array = QuantumArray(qtype, shape = 3) >>> q_array.init_state([(np.array([1, 2, 3]), 1), (np.array([1, 2, 2]), 0.5j)]) >>> print(q_array) {OutcomeArray([1, 2, 3]): 0.8, OutcomeArray([1, 2, 2]): 0.2}