quri_parts.core.state.comp_basis module#

class quri_parts.core.state.comp_basis.ComputationalBasisState(n_qubits: int, *, bits: int = 0)#

Bases: CircuitQuantumState

ComputationalBasisState represents a computational basis state. A computational basis state can also be considered as a state given as a result of applying Pauli gates to |00…0> state. It internally holds a phase factor resulted from the applications of Pauli gates.

Parameters:
  • n_qubits – The number of qubits.

  • bits – An integer representing a bit string of the computational basis state.

property qubit_count: int#

Returns the qubit count of the state.

property circuit: ImmutableQuantumCircuit#

Circuit to build the quantum state.

with_pauli_gate_applied(gate: QuantumGate) ComputationalBasisState#

Apply a Pauli gate to the quantum state.

with_gates_applied(gates: NonParametricQuantumCircuit | Sequence[QuantumGate]) ComputationalBasisState | GeneralCircuitQuantumState#

Returns a new state with the gates applied.

The original state is not changed.

property bits: int#

An integer representing a bit string of the computational basis state.

property phase: float#

The phase of the state.

quri_parts.core.state.comp_basis.comp_basis_superposition(state_a: ComputationalBasisState, state_b: ComputationalBasisState, theta: float, phi: float) GeneralCircuitQuantumState#

Return a superposition state (as GeneralCircuitQuantumState) composed of two ComputationalBasisState.

\[\cos \theta | state_a \rangle + e^{i \phi} \sin \theta | state_b \rangle\]

Raises ValueError if the qubit counts of the two states are different.