aboutsummaryrefslogtreecommitdiff
path: root/libpsi-core/src/core/gates.rs
blob: e9077adac2679c82da98193f1df0f17f711212f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::{complex, matrix, QuantumGate};

#[rustfmt::skip]
lazy_static::lazy_static! {
    pub static ref HADAMARD: QuantumGate = matrix!([complex!(1.0, 0.0), complex!( 1.0, 0.0)];
                                                   [complex!(1.0, 0.0), complex!(-1.0, 0.0)]) *
                                           complex!(1.0/2.0_f64.sqrt(), 0.0);

    pub static ref PAULI_X: QuantumGate = matrix!([complex!(0.0, 0.0), complex!(1.0, 0.0)];
                                                  [complex!(1.0, 0.0), complex!(0.0, 0.0)]);

    pub static ref PAULI_Y: QuantumGate = matrix!([complex!(0.0, 0.0), complex!(0.0, -1.0)];
                                                  [complex!(0.0, 1.0), complex!(0.0,  0.0)]);

    pub static ref PAULI_Z: QuantumGate = matrix!([complex!(1.0, 0.0), complex!( 0.0, 0.0)];
                                                  [complex!(0.0, 0.0), complex!(-1.0, 0.0)]);

    pub static ref CNOT: QuantumGate = matrix!([complex!(1.0, 0.0), complex!(0.0, 0.0), complex!(0.0, 0.0), complex!(0.0, 0.0)];
                                               [complex!(0.0, 0.0), complex!(1.0, 0.0), complex!(0.0, 0.0), complex!(0.0, 0.0)];
                                               [complex!(0.0, 0.0), complex!(0.0, 0.0), complex!(0.0, 0.0), complex!(1.0, 0.0)];
                                               [complex!(0.0, 0.0), complex!(0.0, 0.0), complex!(1.0, 0.0), complex!(0.0, 0.0)]);
}