diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-10-31 10:31:32 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-10-31 10:31:32 +0000 |
commit | f637161ac988979b35ab7254f753a67df8ec812a (patch) | |
tree | 11291699868a50a8586ac97281ca26dc66209c28 /lib/Numeric/LinearAlgebra/Algorithms.hs | |
parent | 2facdf74f267ff81645336528a50696f61bb8670 (diff) |
-norm, +rcond, +kronecker
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 0683956..52f9b6f 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs | |||
@@ -22,7 +22,7 @@ module Numeric.LinearAlgebra.Algorithms ( | |||
22 | -- * Linear Systems | 22 | -- * Linear Systems |
23 | linearSolve, | 23 | linearSolve, |
24 | inv, pinv, | 24 | inv, pinv, |
25 | pinvTol, det, rank, | 25 | pinvTol, det, rank, rcond, |
26 | -- * Matrix factorizations | 26 | -- * Matrix factorizations |
27 | -- ** Singular value decomposition | 27 | -- ** Singular value decomposition |
28 | svd, | 28 | svd, |
@@ -244,10 +244,10 @@ pnormCM PNorm1 m = vectorMax $ constant 1 (rows m) `vXm` liftMatrix (liftVector | |||
244 | pnormCM Infinity m = vectorMax $ liftMatrix (liftVector magnitude) m `mXv` constant 1 (cols m) | 244 | pnormCM Infinity m = vectorMax $ liftMatrix (liftVector magnitude) m `mXv` constant 1 (cols m) |
245 | --pnormCM _ _ = error "p norm not yet defined" | 245 | --pnormCM _ _ = error "p norm not yet defined" |
246 | 246 | ||
247 | -- | Objects which have a p-norm. | ||
248 | -- Using it you can define convenient shortcuts: @norm2 = pnorm PNorm2@, @frobenius = norm2 . flatten@, etc. | ||
247 | class Normed t where | 249 | class Normed t where |
248 | pnorm :: NormType -> t -> Double | 250 | pnorm :: NormType -> t -> Double |
249 | norm :: t -> Double | ||
250 | norm = pnorm PNorm2 | ||
251 | 251 | ||
252 | instance Normed (Vector Double) where | 252 | instance Normed (Vector Double) where |
253 | pnorm = pnormRV | 253 | pnorm = pnormRV |
@@ -356,6 +356,12 @@ uH (pq, tau) = (p,h) | |||
356 | 356 | ||
357 | -------------------------------------------------------------------------- | 357 | -------------------------------------------------------------------------- |
358 | 358 | ||
359 | -- | Reciprocal of the 2-norm condition number of a matrix, computed from the SVD. | ||
360 | rcond :: GenMat t => Matrix t -> Double | ||
361 | rcond m = last s / head s | ||
362 | where (_,s',_) = svd m | ||
363 | s = toList s' | ||
364 | |||
359 | -- | Number of linearly independent rows or columns. | 365 | -- | Number of linearly independent rows or columns. |
360 | rank :: GenMat t => Matrix t -> Int | 366 | rank :: GenMat t => Matrix t -> Int |
361 | rank m | pnorm PNorm1 m < eps = 0 | 367 | rank m | pnorm PNorm1 m < eps = 0 |