summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Algorithms.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-31 10:31:32 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-31 10:31:32 +0000
commitf637161ac988979b35ab7254f753a67df8ec812a (patch)
tree11291699868a50a8586ac97281ca26dc66209c28 /lib/Numeric/LinearAlgebra/Algorithms.hs
parent2facdf74f267ff81645336528a50696f61bb8670 (diff)
-norm, +rcond, +kronecker
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Algorithms.hs12
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
244pnormCM Infinity m = vectorMax $ liftMatrix (liftVector magnitude) m `mXv` constant 1 (cols m) 244pnormCM 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.
247class Normed t where 249class Normed t where
248 pnorm :: NormType -> t -> Double 250 pnorm :: NormType -> t -> Double
249 norm :: t -> Double
250 norm = pnorm PNorm2
251 251
252instance Normed (Vector Double) where 252instance 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.
360rcond :: GenMat t => Matrix t -> Double
361rcond 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.
360rank :: GenMat t => Matrix t -> Int 366rank :: GenMat t => Matrix t -> Int
361rank m | pnorm PNorm1 m < eps = 0 367rank m | pnorm PNorm1 m < eps = 0