summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-06-15 12:52:46 +0200
committerAlberto Ruiz <aruiz@um.es>2015-06-15 12:52:46 +0200
commit7376d022b12a27db5a396f89806a709555c1c522 (patch)
treef5bab9687cf775185f20dbc22713eddb360b495a /packages/base/src/Numeric/LinearAlgebra.hs
parent57487d828065ea219cdb33c9dc177b67c60b34c7 (diff)
documentation, more general cond, remove some unicode, minor changes
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra.hs')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra.hs48
1 files changed, 47 insertions, 1 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra.hs b/packages/base/src/Numeric/LinearAlgebra.hs
index fe524cc..2e6b8ca 100644
--- a/packages/base/src/Numeric/LinearAlgebra.hs
+++ b/packages/base/src/Numeric/LinearAlgebra.hs
@@ -47,7 +47,7 @@ module Numeric.LinearAlgebra (
47 47
48 -- * Products 48 -- * Products
49 -- ** dot 49 -- ** dot
50 dot, (<ยท>), 50 dot, (<.>),
51 -- ** matrix-vector 51 -- ** matrix-vector
52 app, (#>), (<#), (!#>), 52 app, (#>), (<#), (!#>),
53 -- ** matrix-matrix 53 -- ** matrix-matrix
@@ -240,7 +240,53 @@ nullspace m = nullspaceSVD (Left (1*eps)) m (rightSV m)
240-- | return an orthonormal basis of the range space of a matrix. See also 'orthSVD'. 240-- | return an orthonormal basis of the range space of a matrix. See also 'orthSVD'.
241orth m = orthSVD (Left (1*eps)) m (leftSV m) 241orth m = orthSVD (Left (1*eps)) m (leftSV m)
242 242
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-}
243luPacked' x = mutable (luST (magnit 0)) x 271luPacked' x = mutable (luST (magnit 0)) x
244 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-}
245linearSolve' x y = gaussElim x y 291linearSolve' x y = gaussElim x y
246 292