Quantum State Generators API

Quantum State Generators

graphcalc.quantum.generators.basis_state(index: int, *, dim: int = 2, tol: float = 1e-09) QuantumState[source]

Return the computational basis state |index><index| in dimension dim.

graphcalc.quantum.generators.bell_state(which: int = 0, *, tol: float = 1e-09) QuantumState[source]

Return one of the four Bell states on two qubits.

Parameters:
  • which (int, default=0) – Index selecting the Bell state: - 0 : (|00> + |11>) / sqrt(2) - 1 : (|00> - |11>) / sqrt(2) - 2 : (|01> + |10>) / sqrt(2) - 3 : (|01> - |10>) / sqrt(2)

  • tol (float, default=1e-9) – Numerical tolerance passed to QuantumState.

graphcalc.quantum.generators.computational_basis_state(bits: Sequence[int], *, tol: float = 1e-09) QuantumState[source]

Return the computational basis state indexed by a bit string.

Parameters:
  • bits (sequence of int) – Sequence of 0/1 values specifying a basis vector in (C^2)^{⊗ n}.

  • tol (float, default=1e-9) – Numerical tolerance passed to QuantumState.

Examples

bits=(0, 1, 1) returns |011><011|.

graphcalc.quantum.generators.ghz_state(n: int, *, tol: float = 1e-09) QuantumState[source]

Return the n-qubit GHZ state.

|GHZ_n> = (|0...0> + |1...1>) / sqrt(2).

graphcalc.quantum.generators.maximally_mixed_state(dim: int, *, tol: float = 1e-09) QuantumState[source]

Return the maximally mixed state I / dim on a single dim-level system.

graphcalc.quantum.generators.minus_state(*, tol: float = 1e-09) QuantumState[source]

Return the single-qubit |-> state.

|-> = (|0> - |1>) / sqrt(2).

graphcalc.quantum.generators.plus_state(*, tol: float = 1e-09) QuantumState[source]

Return the single-qubit |+> state.

|+> = (|0> + |1>) / sqrt(2).

graphcalc.quantum.generators.w_state(n: int, *, tol: float = 1e-09) QuantumState[source]

Return the n-qubit W state.

|W_n> is the equal superposition of all computational basis states with Hamming weight 1.

graphcalc.quantum.generators.werner_state(p: float, *, tol: float = 1e-09) QuantumState[source]

Return the 2-qubit Werner state

rho = p |Psi^-><Psi^-| + (1-p) I / 4.

Parameters:
  • p (float) – Mixing parameter. Must satisfy 0 <= p <= 1.

  • tol (float, default=1e-9) – Numerical tolerance passed to QuantumState.