aboutsummaryrefslogtreecommitdiff
path: root/libmu/src/core/component.rs
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2024-09-22 10:11:02 +0200
committerhachem <im@hachem.wtf>2024-09-22 10:11:02 +0200
commit53287a755cc8bcef8b4c1324f1ed1f34224e15c4 (patch)
tree145974cff606e06c48dfe1ca2476f21d0ce5a1d2 /libmu/src/core/component.rs
parenta84b6394209e37620e45155a25b3755b38ba8515 (diff)
rename project to psi
Diffstat (limited to 'libmu/src/core/component.rs')
-rw-r--r--libmu/src/core/component.rs51
1 files changed, 0 insertions, 51 deletions
diff --git a/libmu/src/core/component.rs b/libmu/src/core/component.rs
deleted file mode 100644
index bd18b52..0000000
--- a/libmu/src/core/component.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-use crate::{ColumnVector, Complex, Matrix, VectorMatrix};
-
-pub type QuantumRegister = ColumnVector<Complex<f64>>;
-pub type QuantumBit = ColumnVector<Complex<f64>>;
-
-#[macro_export]
-macro_rules! count {
- () => { 0 };
- ($head:expr $(,$tail:expr)*) => { 1 + count!($( $tail ),*) };
-}
-
-#[macro_export]
-macro_rules! qubit {
- ($(($re:expr, $im:expr)),*) => {
- {
- let mut vector = Vec::new();
- $(
- vector.push(complex!($re, $im));
- )*
- QuantumBit::new(vector)
- }
- };
-}
-
-#[macro_export]
-macro_rules! quantum_register {
- ($($bit:expr),*) => {
- {
- const N: usize = count!($($bit),*);
- let bits: [QuantumBit; N] = [$($bit),*];
- QuantumRegister::from(&bits)
- }
- };
-}
-
-impl QuantumBit {
- pub fn get_state(&self) -> i32 {
- (self[1] != Complex::new(0.0, 0.0)) as i32
- }
-}
-
-impl QuantumRegister {
- pub fn from(bits: &[QuantumBit]) -> QuantumRegister {
- let matrices: Vec<Matrix<Complex<f64>>> = bits.iter().map(|bit| bit.to_matrix()).collect();
- let mut result = matrices[0].clone();
- for matrix in &matrices[1..] {
- result = result.kronecker(matrix);
- }
- ColumnVector::from_matrix(&result)
- }
-}