Expand description
§tpt-sci-quantum
A from-scratch qubit state-vector simulator for the tpt-science pillar.
The simulator represents an n-qubit pure state as a length-2^n vector of
complex amplitudes (in the computational basis |0...0> … |1...1>). Gates
are applied in place by iterating over the relevant pairs of basis states, and
measurement samples a basis index from the Born rule distribution.
No external quantum-simulation crates are used: the linear algebra is just complex scalars and explicit index arithmetic over the amplitude vector.
§Examples
Build the Bell state |Φ+⟩ = (|00⟩ + |11⟩)/√2 and check its marginals:
use tpt_sci_quantum::State;
let mut state = State::new(2).unwrap();
state.h(0).unwrap();
state.cnot(0, 1).unwrap();
let p = state.probabilities();
assert!((p[0] - 0.5).abs() < 1e-9);
assert!((p[3] - 0.5).abs() < 1e-9);Re-exports§
pub use tensor::Circuit;pub use tensor::embed_gate_2x2;pub use tensor::kron;pub use density::DensityMatrix;pub use density::Matrix;pub use error::StateError;
Modules§
- density
- Density-matrix representation and Kraus-channel noise application. Density-matrix representation and Kraus-channel noise application.
- error
- Errors produced by state construction and gate application. Errors produced by state construction and gate application.
- tensor
- Tensor-product (Kronecker) circuit formulation built on
tpt-math-linalg. Tensor-product (Kronecker) formulation of qubit circuits.
Structs§
- State
- A pure
n-qubit state stored as a length-2^namplitude vector.