Skip to main content

quantrs2_sim/topological_quantum_simulation/
nonabeliananyons_traits.rs

1//! # NonAbelianAnyons - Trait Implementations
2//!
3//! This module contains trait implementations for `NonAbelianAnyons`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Default`
8//! - `AnyonModelImplementation`
9//!
10//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
11
12use scirs2_core::ndarray::{Array1, Array2, Array3, Array4, Axis};
13use scirs2_core::Complex64;
14
15use super::functions::AnyonModelImplementation;
16use super::types::{AnyonType, NonAbelianAnyons};
17
18impl Default for NonAbelianAnyons {
19    fn default() -> Self {
20        Self::new()
21    }
22}
23
24impl AnyonModelImplementation for NonAbelianAnyons {
25    fn get_anyon_types(&self) -> Vec<AnyonType> {
26        self.anyon_types.clone()
27    }
28    fn fusion_coefficients(&self, a: &AnyonType, b: &AnyonType, c: &AnyonType) -> Complex64 {
29        if let Some(outcomes) = a.fusion_rules.get(&b.label) {
30            if outcomes.contains(&c.label) {
31                Complex64::new(1.0, 0.0)
32            } else {
33                Complex64::new(0.0, 0.0)
34            }
35        } else {
36            Complex64::new(0.0, 0.0)
37        }
38    }
39    fn braiding_matrix(&self, a: &AnyonType, b: &AnyonType) -> Array2<Complex64> {
40        let dim = (a.quantum_dimension * b.quantum_dimension) as usize;
41        let mut matrix = Array2::eye(dim);
42        if !a.is_abelian || !b.is_abelian {
43            let phase = a.r_matrix * b.r_matrix.conj();
44            matrix[[0, 0]] = phase;
45            if dim > 1 {
46                matrix[[1, 1]] = phase.conj();
47            }
48        }
49        matrix
50    }
51    fn f_matrix(
52        &self,
53        _a: &AnyonType,
54        _b: &AnyonType,
55        _c: &AnyonType,
56        _d: &AnyonType,
57    ) -> Array2<Complex64> {
58        Array2::eye(2)
59    }
60    fn is_abelian(&self) -> bool {
61        false
62    }
63    fn name(&self) -> &'static str {
64        "Non-Abelian Anyons"
65    }
66}