Qit
Simple quantum computer simulator library without matrix operations.
Example
All gates can make changes to the qubit using the apply method.
Usage basic gates
use ;
use ;
// 1-Bit Gate
let h_0 = new;
// create |0⟩ Qubit
let q_in = zeros;
let q_out = h_0.apply;
q_out.print_cmps;
// |0⟩ : +0.707 +0.000i
// |1⟩ : +0.707 +0.000i
// 2-Bit Gate
let cx01 = CX new;
// q_in = |01⟩ Qubit
let q_in = from_num;
let q_out = cx01.apply;
q_out.print_cmps;
// |00⟩ : +0.000 +0.000i
// |01⟩ : +0.000 +0.000i
// |10⟩ : +0.000 +0.000i
// |11⟩ : +1.000 +0.000i
// Combine gates into one unitary gate
let x = new;
let cx01 = CX new;
let z = new;
let mut circ = new;
circ.push_ops;
circ.push_ops;
circ.push_ops;
let u = new;
let q_in = from_num;
let q_out = u.apply;
q_out.print_cmps;
// |00⟩ : +0.000 +0.000i
// |01⟩ : +0.000 +0.000i
// |10⟩ : -0.000 -0.000i
// |11⟩ : -1.000 -0.000i
Usage prepared circuits
The circuits module implements a function that gives a circuit created using the structure of the gates module.
use wrapping_qsub_const;
use ;
use U;
let b = vec!;
let sub_2 = wrapping_qsub_const;
let sub_3 = wrapping_qsub_const;
// combine sub_2 and sub_3
let sub_5 = new;
// q_in = |111⟩
let q_in = from_num;
let q_out = sub_5.apply;
q_out.print_cmps;
// |000⟩ : +0.000 +0.000i
// |001⟩ : +0.000 +0.000i
// |010⟩ : +1.000 +0.000i
// |011⟩ : +0.000 +0.000i
// |100⟩ : +0.000 +0.000i
// |101⟩ : +0.000 +0.000i
// |110⟩ : +0.000 +0.000i
// |111⟩ : +0.000 +0.000i
Current version: 0.1.3
Some additional info here
License: MIT