quantrs2_sim/topological_quantum_simulation/
abeliananyons_traits.rs1use scirs2_core::ndarray::{Array1, Array2, Array3, Array4, Axis};
13use scirs2_core::Complex64;
14
15use super::functions::AnyonModelImplementation;
16use super::types::{AbelianAnyons, AnyonType};
17
18impl Default for AbelianAnyons {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl AnyonModelImplementation for AbelianAnyons {
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 a.topological_charge + b.topological_charge == c.topological_charge {
30 Complex64::new(1.0, 0.0)
31 } else {
32 Complex64::new(0.0, 0.0)
33 }
34 }
35 fn braiding_matrix(&self, a: &AnyonType, b: &AnyonType) -> Array2<Complex64> {
36 let phase = a.r_matrix * b.r_matrix.conj();
37 Array2::from_shape_vec((1, 1), vec![phase])
38 .expect("AbelianAnyons::braiding_matrix: 1x1 matrix shape is always valid")
39 }
40 fn f_matrix(
41 &self,
42 _a: &AnyonType,
43 _b: &AnyonType,
44 _c: &AnyonType,
45 _d: &AnyonType,
46 ) -> Array2<Complex64> {
47 Array2::eye(1)
48 }
49 fn is_abelian(&self) -> bool {
50 true
51 }
52 fn name(&self) -> &'static str {
53 "Abelian Anyons"
54 }
55}