summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra.hs56
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Devel.hs2
2 files changed, 4 insertions, 54 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra.hs b/packages/base/src/Numeric/LinearAlgebra.hs
index 2e6b8ca..0b8abbb 100644
--- a/packages/base/src/Numeric/LinearAlgebra.hs
+++ b/packages/base/src/Numeric/LinearAlgebra.hs
@@ -77,10 +77,10 @@ module Numeric.LinearAlgebra (
77 linearSolveLS, 77 linearSolveLS,
78 linearSolveSVD, 78 linearSolveSVD,
79 luSolve, 79 luSolve,
80 luSolve',
80 cholSolve, 81 cholSolve,
81 cgSolve, 82 cgSolve,
82 cgSolve', 83 cgSolve',
83 linearSolve',
84 84
85 -- * Inverse and pseudoinverse 85 -- * Inverse and pseudoinverse
86 inv, pinv, pinvTol, 86 inv, pinv, pinvTol,
@@ -122,7 +122,7 @@ module Numeric.LinearAlgebra (
122 schur, 122 schur,
123 123
124 -- * LU 124 -- * LU
125 lu, luPacked, luFact, luPacked', 125 lu, luPacked, luPacked', luFact,
126 126
127 -- * Matrix functions 127 -- * Matrix functions
128 expm, 128 expm,
@@ -158,14 +158,13 @@ import Numeric.Vector()
158import Internal.Matrix 158import Internal.Matrix
159import Internal.Container hiding ((<>)) 159import Internal.Container hiding ((<>))
160import Internal.Numeric hiding (mul) 160import Internal.Numeric hiding (mul)
161import Internal.Algorithms hiding (linearSolve,Normed,orth,luPacked',linearSolve') 161import Internal.Algorithms hiding (linearSolve,Normed,orth,luPacked',linearSolve',luSolve')
162import qualified Internal.Algorithms as A 162import qualified Internal.Algorithms as A
163import Internal.Util 163import Internal.Util
164import Internal.Random 164import Internal.Random
165import Internal.Sparse((!#>)) 165import Internal.Sparse((!#>))
166import Internal.CG 166import Internal.CG
167import Internal.Conversion 167import Internal.Conversion
168import Internal.ST(mutable)
169 168
170{- | infix synonym of 'mul' 169{- | infix synonym of 'mul'
171 170
@@ -240,53 +239,4 @@ nullspace m = nullspaceSVD (Left (1*eps)) m (rightSV m)
240-- | return an orthonormal basis of the range space of a matrix. See also 'orthSVD'. 239-- | return an orthonormal basis of the range space of a matrix. See also 'orthSVD'.
241orth m = orthSVD (Left (1*eps)) m (leftSV m) 240orth m = orthSVD (Left (1*eps)) m (leftSV m)
242 241
243{- | Experimental implementation of LU factorization
244 working on any Fractional element type, including 'Mod' n 'I' and 'Mod' n 'Z'.
245
246>>> let m = ident 5 + (5><5) [0..] :: Matrix (Z ./. 17)
247(5><5)
248 [ 1, 1, 2, 3, 4
249 , 5, 7, 7, 8, 9
250 , 10, 11, 13, 13, 14
251 , 15, 16, 0, 2, 2
252 , 3, 4, 5, 6, 8 ]
253
254>>> let (l,u,p,s) = luFact $ luPacked' m
255>>> l
256(5><5)
257 [ 1, 0, 0, 0, 0
258 , 6, 1, 0, 0, 0
259 , 12, 7, 1, 0, 0
260 , 7, 10, 7, 1, 0
261 , 8, 2, 6, 11, 1 ]
262>>> u
263(5><5)
264 [ 15, 16, 0, 2, 2
265 , 0, 13, 7, 13, 14
266 , 0, 0, 15, 0, 11
267 , 0, 0, 0, 15, 15
268 , 0, 0, 0, 0, 1 ]
269
270-}
271luPacked' x = mutable (luST (magnit 0)) x
272
273{- | Experimental implementation of gaussian elimination
274 working on any Fractional element type, including 'Mod' n 'I' and 'Mod' n 'Z'.
275
276>>> let a = (2><2) [1,2,3,5] :: Matrix (Z ./. 13)
277(2><2)
278 [ 1, 2
279 , 3, 5 ]
280>>> b
281(2><3)
282 [ 5, 1, 3
283 , 8, 6, 3 ]
284
285>>> let x = linearSolve' a b
286(2><3)
287 [ 4, 7, 4
288 , 7, 10, 6 ]
289
290-}
291linearSolve' x y = gaussElim x y
292 242
diff --git a/packages/base/src/Numeric/LinearAlgebra/Devel.hs b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
index 36c5f03..db4236b 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Devel.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
@@ -43,7 +43,7 @@ module Numeric.LinearAlgebra.Devel(
43 -- ** Mutable Matrices 43 -- ** Mutable Matrices
44 STMatrix, newMatrix, thawMatrix, freezeMatrix, runSTMatrix, 44 STMatrix, newMatrix, thawMatrix, freezeMatrix, runSTMatrix,
45 readMatrix, writeMatrix, modifyMatrix, liftSTMatrix, 45 readMatrix, writeMatrix, modifyMatrix, liftSTMatrix,
46 mutable, extractMatrix, setMatrix, rowOper, RowOper(..), RowRange(..), ColRange(..), 46 mutable, extractMatrix, setMatrix, rowOper, RowOper(..), RowRange(..), ColRange(..), gemmm, Slice(..),
47 -- ** Unsafe functions 47 -- ** Unsafe functions
48 newUndefinedVector, 48 newUndefinedVector,
49 unsafeReadVector, unsafeWriteVector, 49 unsafeReadVector, unsafeWriteVector,