diff options
-rw-r--r-- | hmatrix.cabal | 7 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests/Properties.hs | 5 |
4 files changed, 19 insertions, 1 deletions
diff --git a/hmatrix.cabal b/hmatrix.cabal index 5416c09..894bff0 100644 --- a/hmatrix.cabal +++ b/hmatrix.cabal | |||
@@ -51,6 +51,10 @@ flag tests | |||
51 | description: Build tests | 51 | description: Build tests |
52 | default: True | 52 | default: True |
53 | 53 | ||
54 | flag dd | ||
55 | description: svd = zgesdd | ||
56 | default: True | ||
57 | |||
54 | flag mkl | 58 | flag mkl |
55 | description: Link with Intel's MKL optimized libraries. | 59 | description: Link with Intel's MKL optimized libraries. |
56 | default: False | 60 | default: False |
@@ -119,6 +123,9 @@ library | |||
119 | if flag(unsafe) | 123 | if flag(unsafe) |
120 | cpp-options: -DUNSAFE | 124 | cpp-options: -DUNSAFE |
121 | 125 | ||
126 | if !flag(dd) | ||
127 | cpp-options: -DNOZGESDD | ||
128 | |||
122 | if impl(ghc < 6.10.2) | 129 | if impl(ghc < 6.10.2) |
123 | cpp-options: -DFINIT | 130 | cpp-options: -DFINIT |
124 | 131 | ||
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 0f2ccef..d0f533b 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs | |||
@@ -129,7 +129,11 @@ instance Field Double where | |||
129 | multiply' = multiplyR | 129 | multiply' = multiplyR |
130 | 130 | ||
131 | instance Field (Complex Double) where | 131 | instance Field (Complex Double) where |
132 | #ifdef NOZGESDD | ||
133 | svd' = svdC | ||
134 | #else | ||
132 | svd' = svdCd | 135 | svd' = svdCd |
136 | #endif | ||
133 | thinSVD' = thinSVDCd | 137 | thinSVD' = thinSVDCd |
134 | sv' = svC | 138 | sv' = svC |
135 | luPacked' = luC | 139 | luPacked' = luC |
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs index 922bfd5..4910b67 100644 --- a/lib/Numeric/LinearAlgebra/Tests.hs +++ b/lib/Numeric/LinearAlgebra/Tests.hs | |||
@@ -229,6 +229,10 @@ runTests n = do | |||
229 | test (svdProp1a svdC) | 229 | test (svdProp1a svdC) |
230 | test (svdProp1a svdRd) | 230 | test (svdProp1a svdRd) |
231 | test (svdProp1a svdCd) | 231 | test (svdProp1a svdCd) |
232 | test (svdProp1b svdR) | ||
233 | test (svdProp1b svdC) | ||
234 | test (svdProp1b svdRd) | ||
235 | test (svdProp1b svdCd) | ||
232 | test (svdProp2 thinSVDR) | 236 | test (svdProp2 thinSVDR) |
233 | test (svdProp2 thinSVDC) | 237 | test (svdProp2 thinSVDC) |
234 | test (svdProp2 thinSVDRd) | 238 | test (svdProp2 thinSVDRd) |
diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs index 6d176fa..618094b 100644 --- a/lib/Numeric/LinearAlgebra/Tests/Properties.hs +++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs | |||
@@ -29,7 +29,7 @@ module Numeric.LinearAlgebra.Tests.Properties ( | |||
29 | pinvProp, | 29 | pinvProp, |
30 | detProp, | 30 | detProp, |
31 | nullspaceProp, | 31 | nullspaceProp, |
32 | svdProp1, svdProp1a, svdProp2, svdProp3, svdProp4, | 32 | svdProp1, svdProp1a, svdProp1b, svdProp2, svdProp3, svdProp4, |
33 | svdProp5a, svdProp5b, svdProp6a, svdProp6b, svdProp7, | 33 | svdProp5a, svdProp5b, svdProp6a, svdProp6b, svdProp7, |
34 | eigProp, eigSHProp, eigProp2, eigSHProp2, | 34 | eigProp, eigSHProp, eigProp2, eigSHProp2, |
35 | qrProp, rqProp, | 35 | qrProp, rqProp, |
@@ -137,6 +137,9 @@ svdProp1a svdfun m = m |~| u <> real d <> trans v && unitary u && unitary v wher | |||
137 | (u,s,v) = svdfun m | 137 | (u,s,v) = svdfun m |
138 | d = diagRect s (rows m) (cols m) | 138 | d = diagRect s (rows m) (cols m) |
139 | 139 | ||
140 | svdProp1b svdfun m = unitary u && unitary v where | ||
141 | (u,_,v) = svdfun m | ||
142 | |||
140 | -- thinSVD | 143 | -- thinSVD |
141 | svdProp2 thinSVDfun m = m |~| u <> diag (real s) <> trans v && orthonormal u && orthonormal v && dim s == min (rows m) (cols m) | 144 | svdProp2 thinSVDfun m = m |~| u <> diag (real s) <> trans v && orthonormal u && orthonormal v && dim s == min (rows m) (cols m) |
142 | where (u,s,v) = thinSVDfun m | 145 | where (u,s,v) = thinSVDfun m |