1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use crate::{complex, matrix, QuantumGate};
#[rustfmt::skip]
lazy_static::lazy_static! {
pub static ref HADAMARD: QuantumGate<'static> = QuantumGate {
name: "H",
matrix: 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<'static> = QuantumGate {
name: "Pauli-X",
matrix: 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<'static> = QuantumGate {
name: "Pauli-Y",
matrix: 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<'static> = QuantumGate {
name: "Pauli-Z",
matrix: 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<'static> = QuantumGate {
name: "CNOT",
matrix: 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)])
};
}
|