Quantum State Preparation#
- prepare(qv, target_array, reversed=False)[source]#
This method performs quantum state preparation. Given a vector
, the function acts as- Parameters:
- qvQuantumVariable
The quantum variable on which to apply state preparation.
- target_arraynumpy.ndarray
The vector
.- reversedboolean
If set to
True
, the endianness is reversed. The default isFalse
.
Examples
We create a QuantumFloat and prepare the state
for .b = np.array([0,1,2,3]) qf = QuantumFloat(2) prepare(qf, b) res_dict = qf.get_measurement() for k, v in res_dict.items(): res_dict[k] = v**0.5 for k, v in res_dict.items(): res_dict[k] = v/res_dict[1.0] print(res_dict) # Yields: {3: 2.9999766670425863, 2: 1.999965000393743, 1: 1.0}