diff options
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra.hs')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra.hs | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra.hs b/packages/base/src/Numeric/LinearAlgebra.hs index e899445..0b8abbb 100644 --- a/packages/base/src/Numeric/LinearAlgebra.hs +++ b/packages/base/src/Numeric/LinearAlgebra.hs | |||
@@ -81,7 +81,6 @@ module Numeric.LinearAlgebra ( | |||
81 | cholSolve, | 81 | cholSolve, |
82 | cgSolve, | 82 | cgSolve, |
83 | cgSolve', | 83 | cgSolve', |
84 | linearSolve', | ||
85 | 84 | ||
86 | -- * Inverse and pseudoinverse | 85 | -- * Inverse and pseudoinverse |
87 | inv, pinv, pinvTol, | 86 | inv, pinv, pinvTol, |
@@ -123,7 +122,7 @@ module Numeric.LinearAlgebra ( | |||
123 | schur, | 122 | schur, |
124 | 123 | ||
125 | -- * LU | 124 | -- * LU |
126 | lu, luPacked, luFact, luPacked', | 125 | lu, luPacked, luPacked', luFact, |
127 | 126 | ||
128 | -- * Matrix functions | 127 | -- * Matrix functions |
129 | expm, | 128 | expm, |
@@ -166,7 +165,6 @@ import Internal.Random | |||
166 | import Internal.Sparse((!#>)) | 165 | import Internal.Sparse((!#>)) |
167 | import Internal.CG | 166 | import Internal.CG |
168 | import Internal.Conversion | 167 | import Internal.Conversion |
169 | import Internal.ST(mutable) | ||
170 | 168 | ||
171 | {- | infix synonym of 'mul' | 169 | {- | infix synonym of 'mul' |
172 | 170 | ||
@@ -241,53 +239,4 @@ nullspace m = nullspaceSVD (Left (1*eps)) m (rightSV m) | |||
241 | -- | 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'. |
242 | orth m = orthSVD (Left (1*eps)) m (leftSV m) | 240 | orth m = orthSVD (Left (1*eps)) m (leftSV m) |
243 | 241 | ||
244 | {- | Experimental implementation of LU factorization | ||
245 | working on any Fractional element type, including 'Mod' n 'I' and 'Mod' n 'Z'. | ||
246 | |||
247 | >>> let m = ident 5 + (5><5) [0..] :: Matrix (Z ./. 17) | ||
248 | (5><5) | ||
249 | [ 1, 1, 2, 3, 4 | ||
250 | , 5, 7, 7, 8, 9 | ||
251 | , 10, 11, 13, 13, 14 | ||
252 | , 15, 16, 0, 2, 2 | ||
253 | , 3, 4, 5, 6, 8 ] | ||
254 | |||
255 | >>> let (l,u,p,s) = luFact $ luPacked' m | ||
256 | >>> l | ||
257 | (5><5) | ||
258 | [ 1, 0, 0, 0, 0 | ||
259 | , 6, 1, 0, 0, 0 | ||
260 | , 12, 7, 1, 0, 0 | ||
261 | , 7, 10, 7, 1, 0 | ||
262 | , 8, 2, 6, 11, 1 ] | ||
263 | >>> u | ||
264 | (5><5) | ||
265 | [ 15, 16, 0, 2, 2 | ||
266 | , 0, 13, 7, 13, 14 | ||
267 | , 0, 0, 15, 0, 11 | ||
268 | , 0, 0, 0, 15, 15 | ||
269 | , 0, 0, 0, 0, 1 ] | ||
270 | |||
271 | -} | ||
272 | luPacked' x = mutable (luST (magnit 0)) x | ||
273 | |||
274 | {- | Experimental implementation of gaussian elimination | ||
275 | working on any Fractional element type, including 'Mod' n 'I' and 'Mod' n 'Z'. | ||
276 | |||
277 | >>> let a = (2><2) [1,2,3,5] :: Matrix (Z ./. 13) | ||
278 | (2><2) | ||
279 | [ 1, 2 | ||
280 | , 3, 5 ] | ||
281 | >>> b | ||
282 | (2><3) | ||
283 | [ 5, 1, 3 | ||
284 | , 8, 6, 3 ] | ||
285 | |||
286 | >>> let x = linearSolve' a b | ||
287 | (2><3) | ||
288 | [ 4, 7, 4 | ||
289 | , 7, 10, 6 ] | ||
290 | |||
291 | -} | ||
292 | linearSolve' x y = gaussElim x y | ||
293 | 242 | ||