summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-04-10 09:59:43 +0200
committerAlberto Ruiz <aruiz@um.es>2015-04-10 09:59:43 +0200
commitfde36f1224d4b87a32019bd9519d0aba4315792b (patch)
tree77f76e91ffdad43f4050e97e9fd8f9eab62b2a77 /packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
parent4dc1ef825642ef4ecf86095c08b933cffe59f855 (diff)
conj trans in right singular vectors fo complex matrices, adapt pinvTol and nullspaceSVD
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Algorithms.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
index a113d48..0e085c1 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
@@ -228,7 +228,9 @@ fromList [35.18264833189422,1.4769076999800903,1.089145439970417e-15]
228 228
229-} 229-}
230svd :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) 230svd :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t)
231svd = {-# SCC "svd" #-} svd' 231svd = {-# SCC "svd" #-} g . svd'
232 where
233 g (u,s,v) = (u,s,tr v)
232 234
233{- | A version of 'svd' which returns only the @min (rows m) (cols m)@ singular vectors of @m@. 235{- | A version of 'svd' which returns only the @min (rows m) (cols m)@ singular vectors of @m@.
234 236
@@ -272,7 +274,10 @@ fromList [35.18264833189422,1.4769076999800903,1.089145439970417e-15]
272 274
273-} 275-}
274thinSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) 276thinSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t)
275thinSVD = {-# SCC "thinSVD" #-} thinSVD' 277thinSVD = {-# SCC "thinSVD" #-} g . thinSVD'
278 where
279 g (u,s,v) = (u,s,tr v)
280
276 281
277-- | Singular values only. 282-- | Singular values only.
278singularValues :: Field t => Matrix t -> Vector Double 283singularValues :: Field t => Matrix t -> Vector Double
@@ -587,7 +592,7 @@ m = (3><3) [ 1, 0, 0
587-} 592-}
588 593
589pinvTol :: Field t => Double -> Matrix t -> Matrix t 594pinvTol :: Field t => Double -> Matrix t -> Matrix t
590pinvTol t m = conj v' `mXm` diag s' `mXm` ctrans u' where 595pinvTol t m = v' `mXm` diag s' `mXm` ctrans u' where
591 (u,s,v) = thinSVD m 596 (u,s,v) = thinSVD m
592 sl@(g:_) = toList s 597 sl@(g:_) = toList s
593 s' = real . fromList . map rec $ sl 598 s' = real . fromList . map rec $ sl
@@ -649,7 +654,7 @@ nullspaceSVD hint a (s,v) = vs where
649 k = case hint of 654 k = case hint of
650 Right t -> t 655 Right t -> t
651 _ -> rankSVD tol a s 656 _ -> rankSVD tol a s
652 vs = conj (dropColumns k v) 657 vs = dropColumns k v
653 658
654 659
655-- | The nullspace of a matrix. See also 'nullspaceSVD'. 660-- | The nullspace of a matrix. See also 'nullspaceSVD'.