packages feed

jackpolynomials 1.0.0.1 → 1.1.0.0

raw patch · 5 files changed

+101/−29 lines, 5 filesdep +hspraydep +jackpolynomialsdep +tastydep −mpolynomialsPVP ok

version bump matches the API change (PVP)

Dependencies added: hspray, jackpolynomials, tasty, tasty-hunit

Dependencies removed: mpolynomials

API changes (from Hackage documentation)

- Math.Algebra.JackPol: jackPol :: forall a. (Fractional a, Ord a, C a) => Int -> Partition -> a -> Polynomial a
+ Math.Algebra.JackPol: jackPol :: forall a. (Fractional a, Ord a, C a) => Int -> Partition -> a -> Spray a
- Math.Algebra.JackPol: schurPol :: Int -> Partition -> Polynomial Int
+ Math.Algebra.JackPol: schurPol :: Int -> Partition -> Spray Int
- Math.Algebra.JackPol: zonalPol :: (Fractional a, Ord a, C a) => Int -> Partition -> Polynomial a
+ Math.Algebra.JackPol: zonalPol :: (Fractional a, Ord a, C a) => Int -> Partition -> Spray a

Files

CHANGELOG.md view
@@ -5,3 +5,8 @@ 1.0.0.1 ------- * removed the upper bounds of the dependencies++1.1.0.0+-------+* replaced the 'mpolynomials' dependency with 'hspray'+* unit tests
README.md view
@@ -8,23 +8,17 @@ ```haskell import Math.Algebra.Jack import Data.Ratio-jackPol [1, 1] [3, 1] (2%1)+jack [1, 1] [3, 1] (2%1) -- 48 % 1 ```  ```haskell import Math.Algebra.JackPol import Data.Ratio-import Math.Algebra.MultiPol+import Math.Algebra.Spray jp = jackPol 2 [3, 1] (2%1)-jp--- (M (Monomial {coefficient = 18 % 1, powers = fromList [1,3]}) ---  :+: ---  M (Monomial {coefficient = 12 % 1, powers = fromList [2,2]})) ---  :+: ---  M (Monomial {coefficient = 18 % 1, powers = fromList [3,1]})-prettyPol show "x" jp+prettySpray show "x" jp -- "(18 % 1) * x^(1, 3) + (12 % 1) * x^(2, 2) + (18 % 1) * x^(3, 1)"-evalPoly jp [1, 1]+evalSpray jp [1, 1] -- 48 % 1 ```
jackpolynomials.cabal view
@@ -1,6 +1,6 @@ cabal-version:      >=1.10 name:               jackpolynomials-version:            1.0.0.1+version:            1.1.0.0 license:            GPL-3 license-file:       LICENSE copyright:          2022 Stéphane Laurent@@ -19,7 +19,7 @@  source-repository head     type:     git-    location: https://github.com/stla/jack+    location: https://github.com/stla/jackpolynomials  library     exposed-modules:@@ -37,5 +37,17 @@         array >=0.5.4.0,         lens >=5.0.1,         math-functions >=0.3.4.2,-        mpolynomials >=0.1.0.0,+        hspray >=0.1.0.0,         numeric-prelude >=0.4.4++test-suite unit-tests+    type:             exitcode-stdio-1.0+    main-is:          Main.hs+    hs-source-dirs:   tests/+    default-language: Haskell2010+    build-depends:+        base >=4.7 && <5,+        tasty,+        tasty-hunit,+        jackpolynomials,+        hspray
src/Math/Algebra/JackPol.hs view
@@ -9,16 +9,16 @@ import           Data.Maybe                 ( fromJust, isJust ) import           Math.Algebra.Jack.Internal ( _betaratio', hookLengths, _N                                             , _isPartition, Partition )-import           Math.Algebra.MultiPol      ( (*^), (^**^), (^*^), (^+^)-                              , constant, lone, Polynomial )-import Numeric.SpecFunctions  ( factorial )+import           Math.Algebra.Hspray        ( (*^), (^**^), (^*^), (^+^)+                                            , constantSpray, lone, Spray )+import           Numeric.SpecFunctions      ( factorial )  -- | Symbolic Jack polynomial jackPol :: forall a. (Fractional a, Ord a, AR.C a)    => Int -- ^ number of variables   -> Partition -- ^ partition of integers   -> a -- ^ alpha parameter-  -> Polynomial a+  -> Spray a jackPol n lambda alpha =   case _isPartition lambda && alpha > 0 of     False -> if _isPartition lambda@@ -27,16 +27,16 @@     True -> jac (length x) 0 lambda lambda arr0 1       where       nll = _N lambda lambda-      x = map lone [1 .. n] :: [Polynomial a]+      x = map lone [1 .. n] :: [Spray a]       arr0 = listArray ((1, 1), (nll, n)) (replicate (nll * n) Nothing)       theproduct :: Int -> a       theproduct nu0 = if nu0 <= 1         then AR.one         else AR.product $ map (\i -> alpha * fromIntegral i + 1) [1 .. nu0-1]-      jac :: Int -> Int -> Partition -> Partition -> Array (Int,Int) (Maybe (Polynomial a)) -> a -> Polynomial a+      jac :: Int -> Int -> Partition -> Partition -> Array (Int,Int) (Maybe (Spray a)) -> a -> Spray a       jac m k mu nu arr beta-        | null nu || head nu == 0 || m == 0 = constant 1-        | length nu > m && nu!!m > 0 = constant 0+        | null nu || head nu == 0 || m == 0 = constantSpray 1+        | length nu > m && nu!!m > 0 = constantSpray 0         | m == 1 = theproduct (head nu) *^ (head x ^**^ head nu)          | k == 0 && isJust (arr ! (_N lambda nu, m)) =                       fromJust $ arr ! (_N lambda nu, m)@@ -44,7 +44,7 @@           where             s = go (beta *^ (jac (m-1) 0 nu nu arr 1 ^*^ ((x!!(m-1)) ^**^ (sum mu - sum nu))))                 (max 1 k)-            go :: Polynomial a -> Int -> Polynomial a+            go :: Spray a -> Int -> Spray a             go !ss ii               | length nu < ii || nu!!(ii-1) == 0 = ss               | otherwise =@@ -73,7 +73,7 @@ zonalPol :: (Fractional a, Ord a, AR.C a)    => Int -- ^ number of variables   -> Partition -- ^ partition of integers-  -> Polynomial a+  -> Spray a zonalPol n lambda = c *^ jck   where     k = sum lambda@@ -85,25 +85,25 @@ schurPol ::    Int -- ^ number of variables   -> Partition -- ^ partition of integers-  -> Polynomial Int+  -> Spray Int schurPol n lambda =   case _isPartition lambda of     False -> error "lambda is not a valid integer partition"     True -> sch n 1 lambda arr0       where-        x = map lone [1 .. n] :: [Polynomial Int]+        x = map lone [1 .. n] :: [Spray Int]         nll = _N lambda lambda         arr0 = listArray ((1, 1), (nll, n)) (replicate (nll * n) Nothing)-        sch :: Int -> Int -> [Int] -> Array (Int,Int) (Maybe (Polynomial Int)) -> Polynomial Int+        sch :: Int -> Int -> [Int] -> Array (Int,Int) (Maybe (Spray Int)) -> Spray Int         sch m k nu arr-          | null nu || head nu == 0 || m == 0 = constant 1-          | length nu > m && nu!!m > 0 = constant 0+          | null nu || head nu == 0 || m == 0 = constantSpray 1+          | length nu > m && nu!!m > 0 = constantSpray 0           | m == 1 = head x ^**^ head nu           | isJust (arr ! (_N lambda nu, m)) = fromJust $ arr ! (_N lambda nu, m)           | otherwise = s             where               s = go (sch (m-1) 1 nu arr) k-              go :: Polynomial Int -> Int -> Polynomial Int+              go :: Spray Int -> Int -> Spray Int               go !ss ii                 | length nu < ii || nu!!(ii-1) == 0 = ss                 | otherwise =
+ tests/Main.hs view
@@ -0,0 +1,61 @@+module Main where+import Math.Algebra.JackPol+import Math.Algebra.Jack+import Data.Ratio+import Math.Algebra.Hspray+import Test.Tasty       (defaultMain, testGroup)+import Test.Tasty.HUnit (assertEqual, testCase)++main :: IO ()+main = defaultMain $+  testGroup "Tests"+  [ testCase "jackPol" $ do+      let jp = jackPol 2 [3, 1] (2%1)+      let v = evalSpray jp [1, 1]+      assertEqual ""+        v+        (48%1),++    testCase "jack" $ do+      assertEqual ""+        (jack [1, 1] [3, 1] (2%1))+        (48%1),++    testCase "schurPol" $ do+      let sp1 = schurPol 4 [4]+      let sp2 = schurPol 4 [3, 1]+      let sp3 = schurPol 4 [2, 2]+      let sp4 = schurPol 4 [2, 1, 1]+      let sp5 = schurPol 4 [1, 1, 1, 1]+      let v = evalSpray (sp1 ^+^ 3 *^ sp2 ^+^ 2*^ sp3 ^+^ 3*^ sp4 ^+^ sp5) [2, 2, 2, 2]+      assertEqual ""+        v+        4096,++    testCase "schur" $ do+      let sp1 = schur [1, 1, 1, 1] [4]+      let sp2 = schur [1, 1, 1, 1] [3, 1]+      let sp3 = schur [1, 1, 1, 1] [2, 2]+      let sp4 = schur [1, 1, 1, 1] [2, 1, 1]+      let sp5 = schur [1, 1, 1, 1] [1, 1, 1, 1]+      assertEqual ""+        (sp1 + 3*sp2 + 2*sp3 + 3*sp4 + sp5)+        256,++    testCase "zonalPol" $ do+      let zp1 = zonalPol 4 [3] :: Spray Rational+      let zp2 = zonalPol 4 [2, 1] :: Spray Rational+      let zp3 = zonalPol 4 [1, 1, 1] :: Spray Rational+      let v = evalSpray (zp1 ^+^ zp2 ^+^ zp3) [2, 2, 2, 2]+      assertEqual ""+        v+        512,++    testCase "zonal" $ do+      let zp1 = zonal [2%1, 2%1, 2%1, 2%1] [3]+      let zp2 = zonal [2%1, 2%1, 2%1, 2%1] [2, 1]+      let zp3 = zonal [2%1, 2%1, 2%1, 2%1] [1, 1, 1]+      assertEqual ""+        (zp1 + zp2 + zp3)+        512+  ]