summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-05-22 20:08:22 +0200
committerAlberto Ruiz <aruiz@um.es>2014-05-22 20:08:22 +0200
commitb5125366953a6ae66ff014b736baf79c0feb47dd (patch)
tree70d18652c9c5d1ecd49beb152de5d1bca29fe7f0 /packages/base/src/Numeric
parent9c4406534e826badee79b1fe585c9c11f0fa01a5 (diff)
auxliary container functions
Diffstat (limited to 'packages/base/src/Numeric')
-rw-r--r--packages/base/src/Numeric/Container.hs8
-rw-r--r--packages/base/src/Numeric/LinearAlgebra.hs21
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Devel.hs10
-rw-r--r--packages/base/src/Numeric/Matrix.hs4
4 files changed, 26 insertions, 17 deletions
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 (
32 diag, ident, 32 diag, ident,
33 ctrans, 33 ctrans,
34 -- * Generic operations 34 -- * Generic operations
35 Container(..), Transposable(..), Linear(..), 35 Container,
36 add, mul, sub, divide, equal, scaleRecip, addConstant,
37 scalar, conj, scale, arctan2, cmap,
38 atIndex, minIndex, maxIndex, minElement, maxElement,
39 sumElements, prodElements,
40 step, cond, find, assoc, accum,
41 Transposable(..), Linear(..),
36 -- * Matrix product 42 -- * Matrix product
37 Product(..), udot, dot, (◇), 43 Product(..), udot, dot, (◇),
38 Mul(..), 44 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 (
13 -- * Basic types and data processing 13 -- * Basic types and data processing
14 module Numeric.LinearAlgebra.Data, 14 module Numeric.LinearAlgebra.Data,
15 15
16 -- | The standard numeric classes are defined elementwise: 16 -- * Arithmetic and numeric classes
17 -- |
18 -- The standard numeric classes are defined elementwise:
17 -- 19 --
18 -- >>> fromList [1,2,3] * fromList [3,0,-2 :: Double] 20 -- >>> fromList [1,2,3] * fromList [3,0,-2 :: Double]
19 -- fromList [3.0,0.0,-6.0] 21 -- fromList [3.0,0.0,-6.0]
@@ -38,7 +40,7 @@ module Numeric.LinearAlgebra (
38 -- * Matrix product 40 -- * Matrix product
39 (<.>), 41 (<.>),
40 42
41 -- | The overloaded multiplication operator may need type annotations to remove 43 -- | The overloaded multiplication operators may need type annotations to remove
42 -- ambiguity. In those cases we can also use the specific functions 'mXm', 'mXv', and 'dot'. 44 -- ambiguity. In those cases we can also use the specific functions 'mXm', 'mXv', and 'dot'.
43 -- 45 --
44 -- The matrix x matrix product is also implemented in the "Data.Monoid" instance, where 46 -- The matrix x matrix product is also implemented in the "Data.Monoid" instance, where
@@ -66,6 +68,7 @@ module Numeric.LinearAlgebra (
66 linearSolveSVD, 68 linearSolveSVD,
67 luSolve, 69 luSolve,
68 cholSolve, 70 cholSolve,
71 cgSolve,
69 72
70 -- * Inverse and pseudoinverse 73 -- * Inverse and pseudoinverse
71 inv, pinv, pinvTol, 74 inv, pinv, pinvTol,
@@ -126,7 +129,15 @@ module Numeric.LinearAlgebra (
126 RandDist(..), randomVector, rand, randn, gaussianSample, uniformSample, 129 RandDist(..), randomVector, rand, randn, gaussianSample, uniformSample,
127 130
128 -- * Misc 131 -- * Misc
129 meanCov, peps, relativeError, haussholder, optimiseMult, dot, udot, mXm, mXv, smXv, (<>), (◇), Seed, checkT 132 meanCov, peps, relativeError, haussholder, optimiseMult, dot, udot, mXm, mXv, smXv, (<>), (◇), Seed, checkT,
133 -- * Auxiliary classes
134 Element, Container, Product, Contraction, LSDiv,
135 Complexable(), RealElement(),
136 RealOf, ComplexOf, SingleOf, DoubleOf,
137 IndexOf,
138 Field, Normed,
139 CGMat, Transposable
140
130) where 141) where
131 142
132import Numeric.LinearAlgebra.Data 143import Numeric.LinearAlgebra.Data
@@ -137,5 +148,7 @@ import Numeric.Container
137import Numeric.LinearAlgebra.Algorithms 148import Numeric.LinearAlgebra.Algorithms
138import Numeric.LinearAlgebra.Util 149import Numeric.LinearAlgebra.Util
139import Numeric.LinearAlgebra.Random 150import Numeric.LinearAlgebra.Random
140import Data.Packed.Internal.Sparse(smXv) 151import Numeric.Sparse(smXv)
152import Numeric.LinearAlgebra.Util.CG(cgSolve)
153import Numeric.LinearAlgebra.Util.CG(CGMat)
141 154
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(
49 mapMatrixWithIndex, mapMatrixWithIndexM, mapMatrixWithIndexM_, 49 mapMatrixWithIndex, mapMatrixWithIndexM, mapMatrixWithIndexM_,
50 liftMatrix, liftMatrix2, liftMatrix2Auto, 50 liftMatrix, liftMatrix2, liftMatrix2Auto,
51 51
52 -- * Auxiliary classes
53 Element, Container, Product, Contraction, LSDiv,
54 Complexable(), RealElement(),
55 RealOf, ComplexOf, SingleOf, DoubleOf,
56 IndexOf,
57 Field, Normed
58) where 52) where
59 53
60import Data.Packed.Foreign 54import Data.Packed.Foreign
61import Data.Packed.Development 55import Data.Packed.Development
62import Data.Packed.ST 56import Data.Packed.ST
63import Numeric.Container(Container,Contraction,LSDiv,Product,
64 Complexable(),RealElement(),
65 RealOf, ComplexOf, SingleOf, DoubleOf, IndexOf)
66import Data.Packed 57import Data.Packed
67import Numeric.LinearAlgebra.Algorithms(Field,Normed)
68 58
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
90 mconcat xs = work (partition isScalar xs) 90 mconcat xs = work (partition isScalar xs)
91 where 91 where
92 work (ss,[]) = product ss 92 work (ss,[]) = product ss
93 work (ss,ms) = scale' (product ss) (optimiseMult ms) 93 work (ss,ms) = scl (product ss) (optimiseMult ms)
94 scale' x m 94 scl x m
95 | isScalar x && x00 == 1 = m 95 | isScalar x && x00 == 1 = m
96 | otherwise = scale x00 m 96 | otherwise = scale x00 m
97 where 97 where