summaryrefslogtreecommitdiff
path: root/packages/base/src
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2016-10-13 19:35:12 +0200
committerGitHub <noreply@github.com>2016-10-13 19:35:12 +0200
commitda79bd0e4e075fac9884d48f5d3845b8c261371b (patch)
tree6b73fde540e7d6d2929c12dde62197892e209de1 /packages/base/src
parent655ff1d1da7d8d69a62f0dfbc7022ec3224fc7f6 (diff)
parent9770dfb1bcfac32f05dd848a560c1e1824f2f7b9 (diff)
Merge pull request #205 from kjslag/compactSVDTol3
add compactSVDTol
Diffstat (limited to 'packages/base/src')
-rw-r--r--packages/base/src/Internal/Algorithms.hs8
-rw-r--r--packages/base/src/Numeric/LinearAlgebra.hs1
2 files changed, 7 insertions, 2 deletions
diff --git a/packages/base/src/Internal/Algorithms.hs b/packages/base/src/Internal/Algorithms.hs
index d5cf98e..1ccd3a2 100644
--- a/packages/base/src/Internal/Algorithms.hs
+++ b/packages/base/src/Internal/Algorithms.hs
@@ -292,9 +292,13 @@ fromList [35.18264833189422,1.4769076999800903]
292 292
293-} 293-}
294compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) 294compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t)
295compactSVD m = (u', subVector 0 d s, v') where 295compactSVD = compactSVDTol 1
296
297-- | @compactSVDTol r@ is similar to 'compactSVDTol', but uses tolerance @tol=r*g*eps*(max rows cols)@ to distinguish nonzero singular values, where @g@ is the greatest singular value.
298compactSVDTol :: Field t => Double -> Matrix t -> (Matrix t, Vector Double, Matrix t)
299compactSVDTol r m = (u', subVector 0 d s, v') where
296 (u,s,v) = thinSVD m 300 (u,s,v) = thinSVD m
297 d = rankSVD (1*eps) m s `max` 1 301 d = rankSVD (r*eps) m s `max` 1
298 u' = takeColumns d u 302 u' = takeColumns d u
299 v' = takeColumns d v 303 v' = takeColumns d v
300 304
diff --git a/packages/base/src/Numeric/LinearAlgebra.hs b/packages/base/src/Numeric/LinearAlgebra.hs
index dee66c1..626ee52 100644
--- a/packages/base/src/Numeric/LinearAlgebra.hs
+++ b/packages/base/src/Numeric/LinearAlgebra.hs
@@ -117,6 +117,7 @@ module Numeric.LinearAlgebra (
117 svd, 117 svd,
118 thinSVD, 118 thinSVD,
119 compactSVD, 119 compactSVD,
120 compactSVDTol,
120 singularValues, 121 singularValues,
121 leftSV, rightSV, 122 leftSV, rightSV,
122 123