packages feed

conjugateGradient 2.0 → 2.1

raw patch · 3 files changed

+23/−17 lines, 3 filesdep ~containersPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: containers

API changes (from Hackage documentation)

- Math.ConjugateGradient: smLookup :: Num a => SM a -> (Int, Int) -> a
- Math.ConjugateGradient: svLookup :: Num a => SV a -> Int -> a
+ Math.ConjugateGradient: lookupSM :: Num a => SM a -> (Int, Int) -> a
+ Math.ConjugateGradient: lookupSV :: Num a => SV a -> Int -> a

Files

Math/ConjugateGradient.hs view
@@ -25,7 +25,7 @@ --        x + 3y = 2 -- @ ----- >>> import Data.IntMap+-- >>> import Data.IntMap.Strict -- >>> import System.Random -- >>> import Math.ConjugateGradient -- >>> let a = SM (2, fromList [(0, SV (fromList [(0, 4), (1, 1)])), (1, SV (fromList [(0, 1), (1, 3)]))]) :: SM Double@@ -43,18 +43,19 @@           -- * Types             SV(..), SM(..)           -- * Sparse operations-          , svLookup, smLookup, addSV, subSV, dotSV, normSV, sMulSV, sMulSM, mulSMV+          , lookupSV, lookupSM, addSV, subSV, dotSV, normSV, sMulSV, sMulSM, mulSMV           -- * Conjugate-Gradient solver           , solveCG           -- * Displaying solutions           , showSolution         ) where -import Data.List                   (intercalate)-import Data.Maybe                  (fromMaybe)-import qualified Data.IntMap as IM (IntMap, lookup, map, unionWith, intersectionWith, fold, fromList)-import System.Random               (Random, RandomGen, randomRs)-import Numeric                     (showFFloat)+import Data.List                          (intercalate)+import Data.Maybe                         (fromMaybe)+import qualified Data.IntMap        as IM (fold)+import qualified Data.IntMap.Strict as IM (IntMap, lookup, map, unionWith, intersectionWith, fromList)+import System.Random                      (Random, RandomGen, randomRs)+import Numeric                            (showFFloat)  -- | A sparse vector containing elements of type 'a'. Only the indices that contain non-@0@ elements should be given -- for efficiency purposes. (Nothing will break if you put in elements that are @0@'s, it's just not as efficient.)@@ -79,12 +80,12 @@ ---------------------------------------------------------------------------------  -- | Look-up a value in a sparse-vector.-svLookup :: Num a => SV a -> Int -> a-svLookup (SV v) k = fromMaybe 0 (k `IM.lookup` v)+lookupSV :: Num a => SV a -> Int -> a+lookupSV (SV v) k = fromMaybe 0 (k `IM.lookup` v)  -- | Look-up a value in a sparse-matrix.-smLookup :: Num a => SM a -> (Int, Int) -> a-smLookup (SM (_, m)) (i, j) = maybe 0 (`svLookup` j) (i `IM.lookup` m)+lookupSM :: Num a => SM a -> (Int, Int) -> a+lookupSM (SM (_, m)) (i, j) = maybe 0 (`lookupSV` j) (i `IM.lookup` m)  -- | Multiply a sparse-vector by a scalar. sMulSV :: Num a => a -> SV a -> SV a@@ -176,9 +177,9 @@   where res   = zipWith3 row a x b         range = [0..n-1]         sf d = showFFloat (Just prec) d ""-        a = [[sf (ma `smLookup` (i, j)) | j <- range] | i <- range]-        x = [sf (vx `svLookup` i) | i <- range]-        b = [sf (vb `svLookup` i) | i <- range]+        a = [[sf (ma `lookupSM` (i, j)) | j <- range] | i <- range]+        x = [sf (vx `lookupSV` i) | i <- range]+        b = [sf (vb `lookupSV` i) | i <- range]         cellWidth = maximum (0 : map length (concat a ++ x ++ b))         row as xv bv = unwords (map pad as) ++ " | " ++ pad xv ++ " = " ++ pad bv         pad s  = reverse $ take (length s `max` cellWidth) $ reverse s ++ repeat ' '
RELEASENOTES view
@@ -1,7 +1,12 @@ Hackage: <http://hackage.haskell.org/package/conjugateGradient> GitHub:  <http://github.com/LeventErkok/conjugateGradient> -Latest Hackage released version: 2.0+Latest Hackage released version: 2.1++Version 2.1, 2013-04-18+======================================================================+  - Use strict int-maps as the underlying container+  - Rename some methods to make them more consistent  Version 2.0, 2013-04-17 ======================================================================
conjugateGradient.cabal view
@@ -1,5 +1,5 @@ Name:          conjugateGradient-Version:       2.0+Version:       2.1 Category:      Math Synopsis:      Sparse matrix linear-equation solver Description:   Sparse matrix linear-equation solver, using the conjugate gradient algorithm. Note that the@@ -29,5 +29,5 @@ Library   default-language: Haskell2010   ghc-options     : -Wall-  Build-Depends   : base >= 4 && < 5, random, containers+  Build-Depends   : base >= 4 && < 5, random, containers >= 0.5   Exposed-modules : Math.ConjugateGradient