From b5125366953a6ae66ff014b736baf79c0feb47dd Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 22 May 2014 20:08:22 +0200 Subject: auxliary container functions --- packages/base/src/Numeric/Container.hs | 8 +++++++- packages/base/src/Numeric/LinearAlgebra.hs | 21 +++++++++++++++++---- packages/base/src/Numeric/LinearAlgebra/Devel.hs | 10 ---------- packages/base/src/Numeric/Matrix.hs | 4 ++-- 4 files changed, 26 insertions(+), 17 deletions(-) (limited to 'packages/base/src/Numeric') diff --git a/packages/base/src/Numeric/Container.hs b/packages/base/src/Numeric/Container.hs index 0633640..067c5fa 100644 --- a/packages/base/src/Numeric/Container.hs +++ b/packages/base/src/Numeric/Container.hs @@ -32,7 +32,13 @@ module Numeric.Container ( diag, ident, ctrans, -- * Generic operations - Container(..), Transposable(..), Linear(..), + Container, + add, mul, sub, divide, equal, scaleRecip, addConstant, + scalar, conj, scale, arctan2, cmap, + atIndex, minIndex, maxIndex, minElement, maxElement, + sumElements, prodElements, + step, cond, find, assoc, accum, + Transposable(..), Linear(..), -- * Matrix product Product(..), udot, dot, (◇), Mul(..), diff --git a/packages/base/src/Numeric/LinearAlgebra.hs b/packages/base/src/Numeric/LinearAlgebra.hs index 549ebd0..9e9151e 100644 --- a/packages/base/src/Numeric/LinearAlgebra.hs +++ b/packages/base/src/Numeric/LinearAlgebra.hs @@ -13,7 +13,9 @@ module Numeric.LinearAlgebra ( -- * Basic types and data processing module Numeric.LinearAlgebra.Data, - -- | The standard numeric classes are defined elementwise: + -- * Arithmetic and numeric classes + -- | + -- The standard numeric classes are defined elementwise: -- -- >>> fromList [1,2,3] * fromList [3,0,-2 :: Double] -- fromList [3.0,0.0,-6.0] @@ -38,7 +40,7 @@ module Numeric.LinearAlgebra ( -- * Matrix product (<.>), - -- | The overloaded multiplication operator may need type annotations to remove + -- | The overloaded multiplication operators may need type annotations to remove -- ambiguity. In those cases we can also use the specific functions 'mXm', 'mXv', and 'dot'. -- -- The matrix x matrix product is also implemented in the "Data.Monoid" instance, where @@ -66,6 +68,7 @@ module Numeric.LinearAlgebra ( linearSolveSVD, luSolve, cholSolve, + cgSolve, -- * Inverse and pseudoinverse inv, pinv, pinvTol, @@ -126,7 +129,15 @@ module Numeric.LinearAlgebra ( RandDist(..), randomVector, rand, randn, gaussianSample, uniformSample, -- * Misc - meanCov, peps, relativeError, haussholder, optimiseMult, dot, udot, mXm, mXv, smXv, (<>), (◇), Seed, checkT + meanCov, peps, relativeError, haussholder, optimiseMult, dot, udot, mXm, mXv, smXv, (<>), (◇), Seed, checkT, + -- * Auxiliary classes + Element, Container, Product, Contraction, LSDiv, + Complexable(), RealElement(), + RealOf, ComplexOf, SingleOf, DoubleOf, + IndexOf, + Field, Normed, + CGMat, Transposable + ) where import Numeric.LinearAlgebra.Data @@ -137,5 +148,7 @@ import Numeric.Container import Numeric.LinearAlgebra.Algorithms import Numeric.LinearAlgebra.Util import Numeric.LinearAlgebra.Random -import Data.Packed.Internal.Sparse(smXv) +import Numeric.Sparse(smXv) +import Numeric.LinearAlgebra.Util.CG(cgSolve) +import Numeric.LinearAlgebra.Util.CG(CGMat) diff --git a/packages/base/src/Numeric/LinearAlgebra/Devel.hs b/packages/base/src/Numeric/LinearAlgebra/Devel.hs index c41db2d..ca9e53a 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Devel.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Devel.hs @@ -49,20 +49,10 @@ module Numeric.LinearAlgebra.Devel( mapMatrixWithIndex, mapMatrixWithIndexM, mapMatrixWithIndexM_, liftMatrix, liftMatrix2, liftMatrix2Auto, - -- * Auxiliary classes - Element, Container, Product, Contraction, LSDiv, - Complexable(), RealElement(), - RealOf, ComplexOf, SingleOf, DoubleOf, - IndexOf, - Field, Normed ) where import Data.Packed.Foreign import Data.Packed.Development import Data.Packed.ST -import Numeric.Container(Container,Contraction,LSDiv,Product, - Complexable(),RealElement(), - RealOf, ComplexOf, SingleOf, DoubleOf, IndexOf) import Data.Packed -import Numeric.LinearAlgebra.Algorithms(Field,Normed) diff --git a/packages/base/src/Numeric/Matrix.hs b/packages/base/src/Numeric/Matrix.hs index 719b591..a9022c6 100644 --- a/packages/base/src/Numeric/Matrix.hs +++ b/packages/base/src/Numeric/Matrix.hs @@ -90,8 +90,8 @@ instance (Container Vector t, Eq t, Num (Vector t), Product t) => M.Monoid (Matr mconcat xs = work (partition isScalar xs) where work (ss,[]) = product ss - work (ss,ms) = scale' (product ss) (optimiseMult ms) - scale' x m + work (ss,ms) = scl (product ss) (optimiseMult ms) + scl x m | isScalar x && x00 == 1 = m | otherwise = scale x00 m where -- cgit v1.2.3