aboutsummaryrefslogtreecommitdiff
path: root/libpsi/src/core/gates.rs
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2024-09-22 14:24:27 +0200
committerhachem <im@hachem.wtf>2024-09-22 14:24:27 +0200
commitae8abfa8335edf856f423e7a60c5bb830a79d5a7 (patch)
tree621e34eef728b971428c20e7bf946289c7dedc67 /libpsi/src/core/gates.rs
parent1a9ef4a7f0cbd4ed848ccf0903ebbbd4fdab6adf (diff)
Refactor and implement other gates
Diffstat (limited to 'libpsi/src/core/gates.rs')
-rw-r--r--libpsi/src/core/gates.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpsi/src/core/gates.rs b/libpsi/src/core/gates.rs
index e69de29..227df9a 100644
--- a/libpsi/src/core/gates.rs
+++ b/libpsi/src/core/gates.rs
@@ -0,0 +1,22 @@
+use crate::{complex, matrix, QuantumGate};
+
+#[rustfmt::skip]
+lazy_static::lazy_static! {
+ 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);
+
+ 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)]);
+
+ 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)]);
+
+ 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)]);
+
+ 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)]);
+}