quri_parts.core.state.state_vector module¶
- StateVectorType: TypeAlias = 'npt.NDArray[np.complex128]'¶
A type alias representing a numerical state vector, equivalent to np.ndarray of complex floats.
- class QuantumStateVectorMixin(n_qubits, vector=None)¶
Bases:
ABC- Parameters:
n_qubits (int)
vector (Optional[Union[StateVectorType, 'npt.ArrayLike']])
- property vector: core.state.state_vector.StateVectorType¶
- draw(output='text', *, max_terms=16, threshold=1e-10, precision=6)¶
Render the statevector.
- Parameters:
output (str) – One of
"text","latex_source","latex","qsphere","hinton", or"bloch_vector". The"latex"option wraps the source inIPython.display.Latexwhen IPython is available; otherwise the raw string is returned. The visualization options return a Matplotlib figure.max_terms (int) – Maximum number of non-negligible terms to include. The rest are truncated.
threshold (float) – Terms with magnitude below this value are treated as 0.
precision (int) – Significant digits used for amplitudes/probabilities.
- Return type:
Any
- class QuantumStateVector(n_qubits, vector=None, circuit=None)¶
Bases:
QuantumStateVectorMixin,CircuitQuantumStateMixin,QuantumStateQuantumStateVector represents a state defined by a state vector with an optional circuit to be applied.
- Parameters:
n_qubits (int)
vector (Optional[Union[StateVectorType, 'npt.ArrayLike']])
circuit (Optional[ImmutableQuantumCircuit])
- property qubit_count: int¶
Returns the qubit count of the state.
- with_gates_applied(gates)¶
Returns a new state with the gates applied.
The original state is not changed.
- Parameters:
gates (circuit.circuit.GateSequence)
- Return type: