diff options
author | Alberto Ruiz <aruiz@um.es> | 2016-10-13 19:35:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-13 19:35:12 +0200 |
commit | da79bd0e4e075fac9884d48f5d3845b8c261371b (patch) | |
tree | 6b73fde540e7d6d2929c12dde62197892e209de1 /packages/base/src/Internal | |
parent | 655ff1d1da7d8d69a62f0dfbc7022ec3224fc7f6 (diff) | |
parent | 9770dfb1bcfac32f05dd848a560c1e1824f2f7b9 (diff) |
Merge pull request #205 from kjslag/compactSVDTol3
add compactSVDTol
Diffstat (limited to 'packages/base/src/Internal')
-rw-r--r-- | packages/base/src/Internal/Algorithms.hs | 8 |
1 files changed, 6 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 | -} |
294 | compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) | 294 | compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) |
295 | compactSVD m = (u', subVector 0 d s, v') where | 295 | compactSVD = 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. | ||
298 | compactSVDTol :: Field t => Double -> Matrix t -> (Matrix t, Vector Double, Matrix t) | ||
299 | compactSVDTol 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 | ||