diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-01-08 16:15:29 +0100 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-01-08 16:15:29 +0100 |
commit | dcc03a4a764cb8683b80758af97fcbcc9aadba73 (patch) | |
tree | 9b526a5c0820d75a531adc8d6d1d4b9ef6e95411 /packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs | |
parent | 5eba1bc309d7845366e8d00849d85426bf8f666d (diff) |
wip on tests
Diffstat (limited to 'packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs')
-rw-r--r-- | packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs index 53fc4d2..e2c3840 100644 --- a/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs +++ b/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs | |||
@@ -26,9 +26,8 @@ module Numeric.LinearAlgebra.Tests.Instances( | |||
26 | 26 | ||
27 | import System.Random | 27 | import System.Random |
28 | 28 | ||
29 | import Numeric.LinearAlgebra | 29 | import Numeric.LinearAlgebra.HMatrix hiding (vector) |
30 | import Numeric.LinearAlgebra.Devel | 30 | import Numeric.LinearAlgebra.Devel |
31 | import Numeric.Container | ||
32 | import Control.Monad(replicateM) | 31 | import Control.Monad(replicateM) |
33 | import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector | 32 | import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector |
34 | ,sized,classify,Testable,Property | 33 | ,sized,classify,Testable,Property |
@@ -130,7 +129,7 @@ instance (Field a, Arbitrary a, Num (Vector a)) => Arbitrary (Her a) where | |||
130 | arbitrary = do | 129 | arbitrary = do |
131 | Sq m <- arbitrary | 130 | Sq m <- arbitrary |
132 | let m' = m/2 | 131 | let m' = m/2 |
133 | return $ Her (m' + ctrans m') | 132 | return $ Her (m' + tr m') |
134 | 133 | ||
135 | #if MIN_VERSION_QuickCheck(2,0,0) | 134 | #if MIN_VERSION_QuickCheck(2,0,0) |
136 | #else | 135 | #else |
@@ -144,7 +143,7 @@ instance ArbitraryField (Complex Double) | |||
144 | 143 | ||
145 | -- a well-conditioned general matrix (the singular values are between 1 and 100) | 144 | -- a well-conditioned general matrix (the singular values are between 1 and 100) |
146 | newtype (WC a) = WC (Matrix a) deriving Show | 145 | newtype (WC a) = WC (Matrix a) deriving Show |
147 | instance (ArbitraryField a) => Arbitrary (WC a) where | 146 | instance (Numeric a, ArbitraryField a) => Arbitrary (WC a) where |
148 | arbitrary = do | 147 | arbitrary = do |
149 | m <- arbitrary | 148 | m <- arbitrary |
150 | let (u,_,v) = svd m | 149 | let (u,_,v) = svd m |
@@ -153,7 +152,7 @@ instance (ArbitraryField a) => Arbitrary (WC a) where | |||
153 | n = min r c | 152 | n = min r c |
154 | sv' <- replicateM n (choose (1,100)) | 153 | sv' <- replicateM n (choose (1,100)) |
155 | let s = diagRect 0 (fromList sv') r c | 154 | let s = diagRect 0 (fromList sv') r c |
156 | return $ WC (u `mXm` real s `mXm` trans v) | 155 | return $ WC (u <> real s <> tr v) |
157 | 156 | ||
158 | #if MIN_VERSION_QuickCheck(2,0,0) | 157 | #if MIN_VERSION_QuickCheck(2,0,0) |
159 | #else | 158 | #else |
@@ -163,14 +162,14 @@ instance (ArbitraryField a) => Arbitrary (WC a) where | |||
163 | 162 | ||
164 | -- a well-conditioned square matrix (the singular values are between 1 and 100) | 163 | -- a well-conditioned square matrix (the singular values are between 1 and 100) |
165 | newtype (SqWC a) = SqWC (Matrix a) deriving Show | 164 | newtype (SqWC a) = SqWC (Matrix a) deriving Show |
166 | instance (ArbitraryField a) => Arbitrary (SqWC a) where | 165 | instance (ArbitraryField a, Numeric a) => Arbitrary (SqWC a) where |
167 | arbitrary = do | 166 | arbitrary = do |
168 | Sq m <- arbitrary | 167 | Sq m <- arbitrary |
169 | let (u,_,v) = svd m | 168 | let (u,_,v) = svd m |
170 | n = rows m | 169 | n = rows m |
171 | sv' <- replicateM n (choose (1,100)) | 170 | sv' <- replicateM n (choose (1,100)) |
172 | let s = diag (fromList sv') | 171 | let s = diag (fromList sv') |
173 | return $ SqWC (u `mXm` real s `mXm` trans v) | 172 | return $ SqWC (u <> real s <> tr v) |
174 | 173 | ||
175 | #if MIN_VERSION_QuickCheck(2,0,0) | 174 | #if MIN_VERSION_QuickCheck(2,0,0) |
176 | #else | 175 | #else |
@@ -180,7 +179,7 @@ instance (ArbitraryField a) => Arbitrary (SqWC a) where | |||
180 | 179 | ||
181 | -- a positive definite square matrix (the eigenvalues are between 0 and 100) | 180 | -- a positive definite square matrix (the eigenvalues are between 0 and 100) |
182 | newtype (PosDef a) = PosDef (Matrix a) deriving Show | 181 | newtype (PosDef a) = PosDef (Matrix a) deriving Show |
183 | instance (ArbitraryField a, Num (Vector a)) | 182 | instance (Numeric a, ArbitraryField a, Num (Vector a)) |
184 | => Arbitrary (PosDef a) where | 183 | => Arbitrary (PosDef a) where |
185 | arbitrary = do | 184 | arbitrary = do |
186 | Her m <- arbitrary | 185 | Her m <- arbitrary |
@@ -188,8 +187,8 @@ instance (ArbitraryField a, Num (Vector a)) | |||
188 | n = rows m | 187 | n = rows m |
189 | l <- replicateM n (choose (0,100)) | 188 | l <- replicateM n (choose (0,100)) |
190 | let s = diag (fromList l) | 189 | let s = diag (fromList l) |
191 | p = v `mXm` real s `mXm` ctrans v | 190 | p = v <> real s <> tr v |
192 | return $ PosDef (0.5 * p + 0.5 * ctrans p) | 191 | return $ PosDef (0.5 * p + 0.5 * tr p) |
193 | 192 | ||
194 | #if MIN_VERSION_QuickCheck(2,0,0) | 193 | #if MIN_VERSION_QuickCheck(2,0,0) |
195 | #else | 194 | #else |