quri_parts.core.state.comp_basis module

X()
class ComputationalBasisState(n_qubits, *, bits=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 (int) – The number of qubits.

  • bits (int) – 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)

Apply a Pauli gate to the quantum state.

Parameters:

gate (QuantumGate)

Return type:

ComputationalBasisState

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:

ComputationalBasisState | GeneralCircuitQuantumState

property bits: int

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

property phase: float

The phase of the state.

sample(n_shots)

Sample the state using qulacs.

Parameters:

n_shots (int)

Return type:

Mapping[int, int | float]

comp_basis_superposition(state_a, state_b, theta, phi)

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.

Parameters:
Return type:

GeneralCircuitQuantumState