MultipletCombiner 0.0.6 → 0.0.7
raw patch · 3 files changed
+29/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Physics.MultipletCombiner: (><^) :: [Int] -> Int -> [[Int]]
Files
- MultipletCombiner.cabal +1/−1
- src/Physics/MultipletCombiner.hs +15/−0
- tests/MultipletCombinerTests.hs +13/−1
MultipletCombiner.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: MultipletCombiner-version: 0.0.6+version: 0.0.7 synopsis: A Haskell implementation for combining SU(n) multiplets description: See README at <https://github.com/mdrslmr/MultipletCombiner> category: physics,library,science,math,groups
src/Physics/MultipletCombiner.hs view
@@ -53,6 +53,7 @@ -- * Kronecker product like operators (><), (>><),+ (><^), -- * Multiplicity calculation multi, multis,@@ -327,11 +328,20 @@ concat [ l >< r | l <- ls ] | otherwise = [] +-- | Produce multiplet structure by combining one multiplet repeatedly+(><^) :: [Int] -> Int -> [[Int]]+(><^) t n | n < 1 = []+(><^) t n = pot [[]] t n+ where pot :: [[Int]] -> [Int] -> Int -> [[Int]]+ pot l r 1 = [r]+ pot l r n = pot l r (n-1) >>< r+ -- ghci> [1,0] >< [1,0] >>< [1,0] -- [[3,0],[1,1],[1,1],[0,0]] -- | Calculate the multiplicity of a multiplet multi :: [Int] -> Int+multi [] = 0 multi is = round $ multt (length is) is multt :: Int -> [Int] -> Ratio Int@@ -347,3 +357,8 @@ -- | Calculate the multiplicities of a list of multiplets multis :: [[Int]] -> [Int] multis = fmap multi+++++
tests/MultipletCombinerTests.hs view
@@ -18,6 +18,7 @@ multi1 = TestCase (assertEqual "n in [2], " 3 (multi [2])) multi2 = TestCase (assertEqual "n in octet [1,1], " 8 (multi [1,1])) multi3 = TestCase (assertEqual "n in decuplet [3,0], " 10 (multi [3,0]))+multi4 = TestCase (assertEqual "empty" 0 (multi [])) yt1 = TestCase (assertEqual "yt [0], " "# \n# \n" (show $ ytSymbols [0]))@@ -30,16 +31,27 @@ yt5 = TestCase (assertEqual "yt [2,1], " "# # # # \n# # \n# \n" (show $ ytSymbols [2,1])) +pot1 = TestCase (assertEqual "]1] ><^ 0" [] ([1] ><^ 0))+pot2 = TestCase (assertEqual "[] ><^ 3" [] ([] ><^ 3))+pot3 = TestCase (assertEqual "[1] ><^ 3" ([1] >< [1] >>< [1]) ([1] ><^ 3))+pot4 = TestCase (assertEqual "[1,0] ><^ 3" ([1,0] >< [1,0] >>< [1,0])+ ([1,0] ><^ 3))+ tests = TestList [TestLabel "comb1" comb1, TestLabel "comb2" comb2, TestLabel "multi1" multi1, TestLabel "multi2" multi2, TestLabel "multi3" multi3,+ TestLabel "multi4" multi4, TestLabel "yt1" yt1, TestLabel "yt2" yt2, TestLabel "yt3" yt3, TestLabel "yt4" yt4,- TestLabel "yt5" yt5]+ TestLabel "yt5" yt5,+ TestLabel "pot1" pot1,+ TestLabel "pot2" pot2,+ TestLabel "pot3" pot3,+ TestLabel "pot4" pot4]