aboutsummaryrefslogtreecommitdiff
path: root/libpsi-core/src/core/gates.rs
blob: 094fec9bde501e1613ab1569875d3c1ffed6d485 (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 = ("H", 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 = ("Pauli-X", 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 = ("Pauli-Y", 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 = ("Pauli-Z", 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 = ("CNOT", 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)]));
}