With some gates implemented like: Hadamard, Pauli-X, Pauli-Y, Pauli-Z and Phase shift
Clone the repo and run with cargo
git clone https://github.com/lukkyye/qubit-rep.git
cargo runInitialize a qubit undetermined state:
let qbit1: Qubit<PolarComplex<f32>> = Qubit::init();Note that, you can especify the float and type as f32 or f64 (recommended f32)
Also, two complex types are implemented (PolarComplex and CartesianComplex) where T: Float
Otherwise, you can initialize with a basis state determined like |0⟩ or |1⟩
let qbit1: Qubit<PolarComplex<f64>> = Qubit::init0();
// or
let qbit2: Qubit<PolarComplex<f64>> = Qubit::init1(); let mut qbit1: Qubit<PolarComplex<f64>> = Qubit::init();
qbit1.hadamard()Note that qbit1 is mutable, because hadamard gate transform qubit state into another one
let mut qbit1: Qubit<CartesianComplex<f64>> = Qubit::init();
qbit1.px(); qbit1.py(); qbit1.pz(); let qbit1: Qubit<PolarComplex<f32>> = Qubit::init();
qbit1.print();Example output: " |φ⟩=0.9716602e^(-2.9490366i)|0⟩+0.2363819e^(2.7047591i)|1⟩ "
let qbit1: Qubit<CartesianComplex<f32>> = Qubit::init();
qbit1.measure()Example output: "P(|0⟩)= 0.9597898, P(|1⟩)= 0.040210187"
