diff options
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Tests')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests/Instances.hs | 6 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests/Properties.hs | 15 |
2 files changed, 10 insertions, 11 deletions
diff --git a/lib/Numeric/LinearAlgebra/Tests/Instances.hs b/lib/Numeric/LinearAlgebra/Tests/Instances.hs index 677ad2b..4e829d2 100644 --- a/lib/Numeric/LinearAlgebra/Tests/Instances.hs +++ b/lib/Numeric/LinearAlgebra/Tests/Instances.hs | |||
@@ -30,9 +30,9 @@ import Control.Monad(replicateM) | |||
30 | 30 | ||
31 | instance (Arbitrary a, RealFloat a) => Arbitrary (Complex a) where | 31 | instance (Arbitrary a, RealFloat a) => Arbitrary (Complex a) where |
32 | arbitrary = do | 32 | arbitrary = do |
33 | r <- arbitrary | 33 | re <- arbitrary |
34 | i <- arbitrary | 34 | im <- arbitrary |
35 | return (r:+i) | 35 | return (re :+ im) |
36 | coarbitrary = undefined | 36 | coarbitrary = undefined |
37 | 37 | ||
38 | chooseDim = sized $ \m -> choose (1,max 1 m) | 38 | chooseDim = sized $ \m -> choose (1,max 1 m) |
diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs index 5663b86..b5321c2 100644 --- a/lib/Numeric/LinearAlgebra/Tests/Properties.hs +++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs | |||
@@ -39,11 +39,10 @@ module Numeric.LinearAlgebra.Tests.Properties ( | |||
39 | ) where | 39 | ) where |
40 | 40 | ||
41 | import Numeric.LinearAlgebra | 41 | import Numeric.LinearAlgebra |
42 | import Numeric.LinearAlgebra.Tests.Instances(Sq(..),Her(..),Rot(..)) | ||
43 | import Test.QuickCheck | 42 | import Test.QuickCheck |
44 | import Debug.Trace | 43 | -- import Debug.Trace |
45 | 44 | ||
46 | debug x = trace (show x) x | 45 | -- debug x = trace (show x) x |
47 | 46 | ||
48 | -- relative error | 47 | -- relative error |
49 | dist :: (Normed t, Num t) => t -> t -> Double | 48 | dist :: (Normed t, Num t) => t -> t -> Double |
@@ -77,7 +76,7 @@ hermitian m = square m && m |~| ctrans m | |||
77 | wellCond m = rcond m > 1/100 | 76 | wellCond m = rcond m > 1/100 |
78 | 77 | ||
79 | positiveDefinite m = minimum (toList e) > 0 | 78 | positiveDefinite m = minimum (toList e) > 0 |
80 | where (e,v) = eigSH m | 79 | where (e,_v) = eigSH m |
81 | 80 | ||
82 | upperTriang m = rows m == 1 || down == z | 81 | upperTriang m = rows m == 1 || down == z |
83 | where down = fromList $ concat $ zipWith drop [1..] (toLists (ctrans m)) | 82 | where down = fromList $ concat $ zipWith drop [1..] (toLists (ctrans m)) |
@@ -107,8 +106,8 @@ pinvProp m = m <> p <> m |~| m | |||
107 | 106 | ||
108 | detProp m = s d1 |~| s d2 | 107 | detProp m = s d1 |~| s d2 |
109 | where d1 = det m | 108 | where d1 = det m |
110 | d2 = det' m * det q | 109 | d2 = det' * det q |
111 | det' m = product $ toList $ takeDiag r | 110 | det' = product $ toList $ takeDiag r |
112 | (q,r) = qr m | 111 | (q,r) = qr m |
113 | s x = fromList [x] | 112 | s x = fromList [x] |
114 | 113 | ||
@@ -147,10 +146,10 @@ schurProp2 m = m |~| u <> s <> ctrans u && unitary u && upperHessenberg s -- fix | |||
147 | 146 | ||
148 | cholProp m = m |~| ctrans c <> c && upperTriang c | 147 | cholProp m = m |~| ctrans c <> c && upperTriang c |
149 | where c = chol m | 148 | where c = chol m |
150 | pos = positiveDefinite m | 149 | -- pos = positiveDefinite m |
151 | 150 | ||
152 | expmDiagProp m = expm (logm m) :~ 7 ~: complex m | 151 | expmDiagProp m = expm (logm m) :~ 7 ~: complex m |
153 | where logm m = matFunc log m | 152 | where logm = matFunc log |
154 | 153 | ||
155 | multProp1 (a,b) = a <> b |~| mulH a b | 154 | multProp1 (a,b) = a <> b |~| mulH a b |
156 | 155 | ||