From fde36f1224d4b87a32019bd9519d0aba4315792b Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Fri, 10 Apr 2015 09:59:43 +0200 Subject: conj trans in right singular vectors fo complex matrices, adapt pinvTol and nullspaceSVD --- packages/base/src/Numeric/LinearAlgebra/Algorithms.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'packages/base/src/Numeric/LinearAlgebra/Algorithms.hs') 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] -} svd :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) -svd = {-# SCC "svd" #-} svd' +svd = {-# SCC "svd" #-} g . svd' + where + g (u,s,v) = (u,s,tr v) {- | A version of 'svd' which returns only the @min (rows m) (cols m)@ singular vectors of @m@. @@ -272,7 +274,10 @@ fromList [35.18264833189422,1.4769076999800903,1.089145439970417e-15] -} thinSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) -thinSVD = {-# SCC "thinSVD" #-} thinSVD' +thinSVD = {-# SCC "thinSVD" #-} g . thinSVD' + where + g (u,s,v) = (u,s,tr v) + -- | Singular values only. singularValues :: Field t => Matrix t -> Vector Double @@ -587,7 +592,7 @@ m = (3><3) [ 1, 0, 0 -} pinvTol :: Field t => Double -> Matrix t -> Matrix t -pinvTol t m = conj v' `mXm` diag s' `mXm` ctrans u' where +pinvTol t m = v' `mXm` diag s' `mXm` ctrans u' where (u,s,v) = thinSVD m sl@(g:_) = toList s s' = real . fromList . map rec $ sl @@ -649,7 +654,7 @@ nullspaceSVD hint a (s,v) = vs where k = case hint of Right t -> t _ -> rankSVD tol a s - vs = conj (dropColumns k v) + vs = dropColumns k v -- | The nullspace of a matrix. See also 'nullspaceSVD'. -- cgit v1.2.3