summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Tests
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-10-02 15:53:10 +0000
committerAlberto Ruiz <aruiz@um.es>2008-10-02 15:53:10 +0000
commit192ac5f4b98517862c37ecf161505396ad223cd8 (patch)
tree811312f28bca2bd18d282bc0be732a17cd8dbcd7 /lib/Numeric/LinearAlgebra/Tests
parent9c6b2af0066f7608301ad685ea5e60753fc3b6ff (diff)
alternative multiply versions
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Tests')
-rw-r--r--lib/Numeric/LinearAlgebra/Tests/Instances.hs16
-rw-r--r--lib/Numeric/LinearAlgebra/Tests/Properties.hs6
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/Numeric/LinearAlgebra/Tests/Instances.hs b/lib/Numeric/LinearAlgebra/Tests/Instances.hs
index af486c8..e7fecf2 100644
--- a/lib/Numeric/LinearAlgebra/Tests/Instances.hs
+++ b/lib/Numeric/LinearAlgebra/Tests/Instances.hs
@@ -20,6 +20,7 @@ module Numeric.LinearAlgebra.Tests.Instances(
20 WC(..), rWC,cWC, 20 WC(..), rWC,cWC,
21 SqWC(..), rSqWC, cSqWC, 21 SqWC(..), rSqWC, cSqWC,
22 PosDef(..), rPosDef, cPosDef, 22 PosDef(..), rPosDef, cPosDef,
23 Consistent(..), rConsist, cConsist,
23 RM,CM, rM,cM 24 RM,CM, rM,cM
24) where 25) where
25 26
@@ -116,6 +117,19 @@ instance (Field a, Arbitrary a) => Arbitrary (PosDef a) where
116 return $ PosDef (0.5 .* p + 0.5 .* ctrans p) 117 return $ PosDef (0.5 .* p + 0.5 .* ctrans p)
117 coarbitrary = undefined 118 coarbitrary = undefined
118 119
120-- a pair of matrices that can be multiplied
121newtype (Consistent a) = Consistent (Matrix a, Matrix a) deriving Show
122instance (Field a, Arbitrary a) => Arbitrary (Consistent a) where
123 arbitrary = do
124 n <- chooseDim
125 k <- chooseDim
126 m <- chooseDim
127 la <- vector (n*k)
128 lb <- vector (k*m)
129 return $ Consistent ((n><k) la, (k><m) lb)
130 coarbitrary = undefined
131
132
119type RM = Matrix Double 133type RM = Matrix Double
120type CM = Matrix (Complex Double) 134type CM = Matrix (Complex Double)
121 135
@@ -140,3 +154,5 @@ cSqWC (SqWC m) = m :: CM
140rPosDef (PosDef m) = m :: RM 154rPosDef (PosDef m) = m :: RM
141cPosDef (PosDef m) = m :: CM 155cPosDef (PosDef m) = m :: CM
142 156
157rConsist (Consistent (a,b)) = (a,b::RM)
158cConsist (Consistent (a,b)) = (a,b::CM)
diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
index 55e9a1b..5663b86 100644
--- a/lib/Numeric/LinearAlgebra/Tests/Properties.hs
+++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
@@ -34,7 +34,8 @@ module Numeric.LinearAlgebra.Tests.Properties (
34 hessProp, 34 hessProp,
35 schurProp1, schurProp2, 35 schurProp1, schurProp2,
36 cholProp, 36 cholProp,
37 expmDiagProp 37 expmDiagProp,
38 multProp1, multProp2
38) where 39) where
39 40
40import Numeric.LinearAlgebra 41import Numeric.LinearAlgebra
@@ -151,3 +152,6 @@ cholProp m = m |~| ctrans c <> c && upperTriang c
151expmDiagProp m = expm (logm m) :~ 7 ~: complex m 152expmDiagProp m = expm (logm m) :~ 7 ~: complex m
152 where logm m = matFunc log m 153 where logm m = matFunc log m
153 154
155multProp1 (a,b) = a <> b |~| mulH a b
156
157multProp2 (a,b) = trans (a <> b) |~| trans b <> trans a