packages feed

sym 0.12.0 → 0.12.1

raw patch · 4 files changed

+21/−19 lines, 4 filesdep −array

Dependencies removed: array

Files

Sym/Internal/CLongArray.hs view
@@ -43,7 +43,7 @@ -- ---------  -- | An array of 'CLong's-newtype CLongArray = CArr (V.Vector CLong) deriving (Show, Eq)+newtype CLongArray = CArr (V.Vector CLong) deriving (Eq)  instance Ord CLongArray where     compare u v =@@ -54,6 +54,9 @@ instance Size CLongArray where     size (CArr w) = V.length w     {-# INLINE size #-}++instance Show CLongArray where+    show w = "fromList " ++ show (toList w)   -- Conversions
Sym/Permgram.hs view
@@ -24,13 +24,14 @@ import Data.List import Control.Monad import Control.Applicative-import Sym.Perm (Perm)+import Sym.Perm (Perm, unsafeAt) import qualified Sym.Perm as P-import Data.Array.Unboxed+import Data.Vector (Vector, (!))+import qualified Data.Vector as V  -- | The purpose of this data type is to assign labels to the indices of -- a given permutation.-type Label a = Array Int a+type Label a = Vector a  -- | A permgram consists of a permutation together with a label for each -- index of the permutation.@@ -42,7 +43,7 @@     }  constituents :: Permgram a -> (Perm, [a])-constituents (PGram v f) = (v, elems f)+constituents (PGram v f) = (v, V.toList f)  instance Show a => Show (Permgram a) where     show w =@@ -61,12 +62,12 @@ -- | Construct a permgram from an underlying permutation and a list of -- labels. permgram :: Perm -> [a] -> Permgram a-permgram v = PGram v . listArray (0, P.size v - 1) . cycle+permgram v = PGram v . V.fromListN (P.size v) . cycle  -- | The inverse permgram. It's obtained by mirroring the permgram in -- the /x=y/ diagonal. inverse :: Permgram a -> Permgram a-inverse (PGram u f) = PGram (P.fromList v) (listArray (0,n-1) (map (f!) v))+inverse (PGram u f) = PGram (P.fromList v) (V.fromListN n (map (f!) v))     where       v = map snd . sort $ zip (P.toList u) [0..] -- v = u^{-1}       n = P.size u@@ -76,7 +77,7 @@ size = P.size . perm  instance Functor Permgram where-    fmap f w = w { label = amap f (label w) }+    fmap f w = w { label = V.map f (label w) }  instance Monad Permgram where     return x = permgram (P.fromList [0]) [x]@@ -87,16 +88,15 @@     (<*>) = ap  joinPermgram :: Permgram (Permgram a) -> Permgram a-joinPermgram w@(PGram u f) = PGram (P.fromList xs) (listArray (0,m-1) ys)+joinPermgram w@(PGram u f) = PGram (P.fromList xs) (V.fromListN m ys)     where-      len = amap size f-      m = sum $ elems len+      len = V.map size f+      m = sum $ V.toList len       n = size w       uInverse = map snd . sort $ zip (P.toList u) [0..]-      a :: UArray Int Int-      a = listArray (0,n-1) . scanl (+) 0 $ map (len!) uInverse+      a = V.fromListN n . scanl (+) 0 $ map (len!) uInverse       (xs, ys) = unzip $ do         i <- [0..n-1]-        let PGram v g = f!i-        let d = a ! (u `P.unsafeAt` i)-        [ (d + v `P.unsafeAt` j, g!j) | j <- [0..len!i-1] ]+        let PGram v g = f ! i+        let d = a ! (u `unsafeAt` i)+        [ (d + v `P.unsafeAt` j, g!j) | j <- [0 .. len!i - 1] ]
sym.cabal view
@@ -1,5 +1,5 @@ name:                sym-version:             0.12.0+version:             0.12.1 synopsis:            Permutations, patterns, and statistics description:   Definitions for permutations with an emphasis on permutation@@ -42,7 +42,6 @@    build-depends:       base >=4.7 && <= 5,                        vector >=0.11,-                       array >=0.4,                        hashable >=1.1,                        containers 
tests/Properties.hs view
@@ -22,7 +22,7 @@ checkN n = quickCheckWithResult stdArgs {maxSuccess = n}  check :: Testable prop => prop -> IO ()-check p = checkN 1000 p >> return ()+check p = void (checkN 1000 p)  -------------------------------------------------------------------------------- -- Generators