summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES11
-rw-r--r--hmatrix.cabal2
-rw-r--r--lib/Numeric/LinearAlgebra/Algorithms.hs23
-rw-r--r--lib/Numeric/LinearAlgebra/Tests.hs5
4 files changed, 28 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 475302e..117acc4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,14 @@
10.7.0.0 10.7.2.0
2======= 2=======
3 3
4- NFData instances for deepseq/parallel-2 4- ranksv
5
60.7.1.0
7=======
8
9- buildVector/buildMatrix
10
11- removed NFData instances
5 12
60.6.0.0 130.6.0.0
7======= 14=======
diff --git a/hmatrix.cabal b/hmatrix.cabal
index 778d113..64fef13 100644
--- a/hmatrix.cabal
+++ b/hmatrix.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix 1Name: hmatrix
2Version: 0.7.1.0 2Version: 0.7.2.0
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs
index f749cc1..954b214 100644
--- a/lib/Numeric/LinearAlgebra/Algorithms.hs
+++ b/lib/Numeric/LinearAlgebra/Algorithms.hs
@@ -63,7 +63,7 @@ module Numeric.LinearAlgebra.Algorithms (
63 haussholder, 63 haussholder,
64 unpackQR, unpackHess, 64 unpackQR, unpackHess,
65 pinvTol, 65 pinvTol,
66 rankSVD, 66 rankSVD, ranksv,
67 nullspaceSVD 67 nullspaceSVD
68) where 68) where
69 69
@@ -262,15 +262,18 @@ rankSVD :: Element t
262 -> Matrix t -- ^ input matrix m 262 -> Matrix t -- ^ input matrix m
263 -> (Matrix t, Vector Double, Matrix t) -- ^ 'svd' of m 263 -> (Matrix t, Vector Double, Matrix t) -- ^ 'svd' of m
264 -> Int -- ^ rank of m 264 -> Int -- ^ rank of m
265rankSVD teps m (_,s,_) = k where 265rankSVD teps m (_,s,_) = ranksv teps (max (rows m) (cols m)) (toList s)
266 sl@(g:_) = toList s 266
267 r = rows m 267-- | Numeric rank of a matrix from its singular values.
268 c = cols m 268ranksv :: Double -- ^ numeric zero (e.g. 1*'eps')
269 tol = fromIntegral (max r c) * g * teps 269 -> Int -- ^ maximum dimension of the matrix
270 s' = fromList . filter (>tol) $ sl 270 -> [Double] -- ^ singular values
271 k = if g > teps 271 -> Int -- ^ rank of m
272 then dim s' 272ranksv teps maxdim s = k where
273 else 0 273 g = maximum s
274 tol = fromIntegral maxdim * g * teps
275 s' = filter (>tol) s
276 k = if g > teps then length s' else 0
274 277
275-- | The machine precision of a Double: @eps = 2.22044604925031e-16@ (the value used by GNU-Octave). 278-- | The machine precision of a Double: @eps = 2.22044604925031e-16@ (the value used by GNU-Octave).
276eps :: Double 279eps :: Double
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs
index 4495396..bf29ee9 100644
--- a/lib/Numeric/LinearAlgebra/Tests.hs
+++ b/lib/Numeric/LinearAlgebra/Tests.hs
@@ -243,6 +243,11 @@ runTests n = do
243 , rootFindingTest 243 , rootFindingTest
244 , utest "randomGaussian" randomTestGaussian 244 , utest "randomGaussian" randomTestGaussian
245 , utest "randomUniform" randomTestUniform 245 , utest "randomUniform" randomTestUniform
246 , utest "buildVector/Matrix" $
247 comp (10 |> [0::Double ..]) == buildVector 10 fromIntegral
248 && ident 5 == buildMatrix 5 5 (\(r,c) -> if r==c then 1::Double else 0)
249 , utest "rank" $ rank ((2><3)[1,0,0,1,6*eps,0]) == 1
250 && rank ((2><3)[1,0,0,1,7*eps,0]) == 2
246 ] 251 ]
247 return () 252 return ()
248 253