diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/base/src/Internal/Algorithms.hs | 8 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra.hs | 1 |
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..7f757d7 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 | ||
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 | ||