diff options
Diffstat (limited to 'packages/base/src/Numeric')
-rw-r--r-- | packages/base/src/Numeric/Container.hs | 8 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra.hs | 21 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Devel.hs | 10 | ||||
-rw-r--r-- | packages/base/src/Numeric/Matrix.hs | 4 |
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 | ||
132 | import Numeric.LinearAlgebra.Data | 143 | import Numeric.LinearAlgebra.Data |
@@ -137,5 +148,7 @@ import Numeric.Container | |||
137 | import Numeric.LinearAlgebra.Algorithms | 148 | import Numeric.LinearAlgebra.Algorithms |
138 | import Numeric.LinearAlgebra.Util | 149 | import Numeric.LinearAlgebra.Util |
139 | import Numeric.LinearAlgebra.Random | 150 | import Numeric.LinearAlgebra.Random |
140 | import Data.Packed.Internal.Sparse(smXv) | 151 | import Numeric.Sparse(smXv) |
152 | import Numeric.LinearAlgebra.Util.CG(cgSolve) | ||
153 | import 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 | ||
60 | import Data.Packed.Foreign | 54 | import Data.Packed.Foreign |
61 | import Data.Packed.Development | 55 | import Data.Packed.Development |
62 | import Data.Packed.ST | 56 | import Data.Packed.ST |
63 | import Numeric.Container(Container,Contraction,LSDiv,Product, | ||
64 | Complexable(),RealElement(), | ||
65 | RealOf, ComplexOf, SingleOf, DoubleOf, IndexOf) | ||
66 | import Data.Packed | 57 | import Data.Packed |
67 | import 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 |