diff --git a/python/tests/test_fusion.py b/python/tests/test_fusion.py index d351078..0f8ba30 100644 --- a/python/tests/test_fusion.py +++ b/python/tests/test_fusion.py @@ -75,3 +75,15 @@ def test_verify_fusion_result(state): assert not fusion.verify_fusion_result(TopoCharge.from_ising(IsingTopoCharge.Vacuum), AnyonModel.Ising) assert not fusion.verify_fusion_result(TopoCharge.from_ising(IsingTopoCharge.Psi), AnyonModel.Ising) assert fusion.verify_fusion_result(TopoCharge.from_ising(IsingTopoCharge.Sigma), AnyonModel.Ising) + +@pytest.mark.fusion +def test_minimum_possible_anyons(state): + + fusion = Fusion(state) + + assert (fusion.minimum_possible_anyons(10, AnyonModel.Ising) == [21,22]) + assert (fusion.minimum_possible_anyons(5, AnyonModel.Ising) == [11,12]) + + + assert(fusion.minimum_possible_anyons(10, AnyonModel.Fibonacci) == [17,18]); + assert(fusion.minimum_possible_anyons(0, AnyonModel.Fibonacci) == [0,1,2,3]); diff --git a/src/fusion/fusion.rs b/src/fusion/fusion.rs index a8520ed..9f94dc9 100644 --- a/src/fusion/fusion.rs +++ b/src/fusion/fusion.rs @@ -165,6 +165,49 @@ impl Fusion { .zip(self.ising_canonical_topo_charge(init_charge).iter()) .all(|(a, b)| *b <= 0 || *a > 0) } + + /// + /// Returns number of sigmas that can be in the initial topological charges of anyons to exactly a certain number of qubits for the Ising model + /// + pub fn ising_possible_sigmas(&self, qubits:u32) -> Vec{ + vec![2*qubits+1, 2*qubits+2] + } + /// + /// Returns number of taus that can be in the initial topological charges of anyons to exactly a certain number of qubits for the Fibonacci model + /// + /// Precondition: Requires qubits <=30 + pub fn fibonacci_possible_taus(&self, qubits:u32) -> Vec { + + if qubits ==0{ + return vec![0,1,2,3]; + } + + let mut possible_taus = Vec::new(); + + let mut n = 1; + + + // We have that the fibonacci recurrence gives us that tau^n = a + b * tau + let mut a = 0; + let mut b = 1; + + // Checks that b < 2^(qubits+1) meaning as otherwise fusing to tau would result in too many qubits + while b < 1 << (qubits+1) { + + // If b >= 2^qubits we have that this will give exactly 'qubits' qubits + if (1 << (qubits)) <= b{ + possible_taus.push(n); + } + + b=a+b; + a=b-a; + + n+=1; + } + // Accounts for the case that we can also fuse to vaccuum + possible_taus.push(n); + possible_taus + } } /// Python Facing Methods @@ -268,4 +311,12 @@ impl Fusion { _ => false, } } + fn minimum_possible_anyons(&self, qubits: u32, anyon_model: &AnyonModel) -> PyResult>{ + match anyon_model{ + AnyonModel::Ising => Ok(self.ising_possible_sigmas(qubits)), + AnyonModel::Fibonacci => Ok(self.fibonacci_possible_taus(qubits)), + _ => Err(PyValueError::new_err("This model is not supported yet")) + } + + } }