uniqc.algorithmics.state_preparation.rotation_prepare module#
Arbitrary state preparation via rotation method.
Uses the Shende–Bullock–Markov (SBM) decomposition: disentangles qubits one at a time, then reverses the gate sequence.
- uniqc.algorithmics.state_preparation.rotation_prepare.rotation_prepare(circuit, target_vector, qubits=None)[source]#
Prepare an arbitrary quantum state from a complex amplitude vector.
Uses the Shende–Bullock–Markov state-preparation algorithm. The method works by computing the circuit that would disentangle the target state back to
|00...0>, collecting the gates, then applying them in reverse order.Gate count: O(2^n) for n qubits.
The vector is automatically normalised.
- Parameters:
- Raises:
ValueError – target_vector length is not a power of 2.
ValueError – target_vector is the zero vector.
- Return type:
None
Example
>>> import numpy as np >>> from uniqc.circuit_builder import Circuit >>> from uniqc.algorithmics.state_preparation import rotation_prepare >>> target = np.array([1, 0, 0, 1]) / np.sqrt(2) # Bell state >>> c = Circuit() >>> rotation_prepare(c, target)