packages feed

np-extras 0.2.0.4 → 0.3

raw patch · 4 files changed

+18/−29 lines, 4 filesdep ~basedep ~containersdep ~numeric-prelude

Dependency ranges changed: base, containers, numeric-prelude

Files

MathObj/FactoredRational.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} -- | A representation of rational numbers as lists of prime powers, --   allowing efficient representation, multiplication and division of --   large numbers, especially of the sort occurring in combinatorial@@ -32,12 +31,7 @@  import Data.Numbers.Primes -#if MIN_VERSION_numeric_prelude(0,2,0) import qualified Algebra.Absolute as Real-#else-import qualified Algebra.Real as Real-import PreludeBase-#endif import NumericPrelude  -- Represent rational numbers by their prime factorizations.@@ -148,9 +142,7 @@ instance Real.C T where   abs FQZero   = FQZero   abs (FQ _ e) = FQ False e-#if MIN_VERSION_numeric_prelude(0,2,0)   signum = Real.signumOrd-#endif  instance ToRational.C T where   toRational FQZero   = 0
MathObj/Monomial.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, PatternGuards #-}+{-# LANGUAGE PatternGuards #-}  -- | Monomials in a countably infinite set of variables x1, x2, x3, ... module MathObj.Monomial@@ -27,11 +27,7 @@ import Data.Ord (comparing) import Data.List (sort, intercalate) -#if MIN_VERSION_numeric_prelude(0,2,0) import NumericPrelude-#else-import PreludeBase-#endif  -- | A monomial is a map from variable indices to integer powers, --   paired with a (polymorphic) coefficient.  Note that negative@@ -50,7 +46,7 @@ --   series, where this ordering corresponds nicely to generation --   of integer partitions. To make the library more general we could --   parameterize monomials by the desired ordering.-data T a = Cons { coeff  :: a +data T a = Cons { coeff  :: a                 , powers :: M.Map Integer Integer                 } @@ -118,7 +114,7 @@  instance (ZeroTestable.C a) => ZeroTestable.C (T a) where   isZero (Cons a _) = isZero a-  + instance (Additive.C a, ZeroTestable.C a) => Additive.C (T a) where   zero = Cons zero M.empty   negate (Cons a m) = Cons (negate a) m@@ -130,14 +126,14 @@  instance (Ring.C a, ZeroTestable.C a) => Ring.C (T a) where   fromInteger n = Cons (fromInteger n) M.empty-  (Cons a1 m1) * (Cons a2 m2) = Cons (a1*a2) +  (Cons a1 m1) * (Cons a2 m2) = Cons (a1*a2)                                      (M.filterWithKey (\_ p -> not (isZero p)) $                                         M.unionWith (+) m1 m2                                      )  -- Partial differentiation with respect to x1. instance (ZeroTestable.C a, Ring.C a) => Differential.C (T a) where-  differentiate (Cons a m) +  differentiate (Cons a m)     | Just 1 <- M.lookup 1 m = Cons a M.empty     | Just p <- M.lookup 1 m = Cons (a*fromInteger p) (M.adjust (subtract 1) 1 m)     | otherwise              = Cons zero M.empty
MathObj/MultiVarPolynomial.hs view
@@ -1,5 +1,5 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-name-shadowing #-}+ -- | Polynomials in a countably infinite set of variables x1, x2, x3, ... module MathObj.MultiVarPolynomial     ( -- * Type@@ -31,10 +31,6 @@ import qualified Data.Map as M  import NumericPrelude-#if MIN_VERSION_numeric_prelude(0,2,0)-#else-import PreludeBase-#endif  -- | A polynomial is just a list of monomials, construed as their sum. --   We maintain the invariant that polynomials are always sorted by
np-extras.cabal view
@@ -1,25 +1,30 @@ name:           np-extras-version:        0.2.0.4+version:        0.3 license:        BSD3 license-file:   LICENSE build-type:     Simple-cabal-version:  >= 1.6-tested-with:    GHC == 6.12.1, GHC == 7.0.3+cabal-version:  >= 1.10+tested-with:    GHC == 7.4.2, GHC == 7.6.1 author:         Brent Yorgey maintainer:     Brent Yorgey <byorgey@cis.upenn.edu>+bug-reports:    http://hub.darcs.net/byorgey/np-extras/issues category:       Math synopsis:       NumericPrelude extras description:    Various extras to extend the NumericPrelude, including                 multivariate polynomials and factored rationals. source-repository head   type:     darcs-  location: http://code.haskell.org/~byorgey/code/np-extras+  location: http://hub.darcs.net/byorgey/np-extras  Library-  build-depends: base >= 3.0 && < 4.5, numeric-prelude >= 0.1.1 && < 0.3,-                 primes >= 0.1.1 && < 0.3, containers >= 0.3 && < 0.5+  build-depends: base >= 3.0 && < 4.7,+                 numeric-prelude >= 0.3 && < 0.4,+                 primes >= 0.1.1 && < 0.3,+                 containers >= 0.3 && < 0.6   exposed-modules:     MathObj.FactoredRational     MathObj.Monomial     MathObj.MultiVarPolynomial-  extensions: NoImplicitPrelude+  default-extensions: NoImplicitPrelude+  other-extensions:   PatternGuards, ViewPatterns+  default-language: Haskell2010