diff options
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Tests/Instances.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests/Instances.hs | 16 |
1 files changed, 16 insertions, 0 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 | ||
121 | newtype (Consistent a) = Consistent (Matrix a, Matrix a) deriving Show | ||
122 | instance (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 | |||
119 | type RM = Matrix Double | 133 | type RM = Matrix Double |
120 | type CM = Matrix (Complex Double) | 134 | type CM = Matrix (Complex Double) |
121 | 135 | ||
@@ -140,3 +154,5 @@ cSqWC (SqWC m) = m :: CM | |||
140 | rPosDef (PosDef m) = m :: RM | 154 | rPosDef (PosDef m) = m :: RM |
141 | cPosDef (PosDef m) = m :: CM | 155 | cPosDef (PosDef m) = m :: CM |
142 | 156 | ||
157 | rConsist (Consistent (a,b)) = (a,b::RM) | ||
158 | cConsist (Consistent (a,b)) = (a,b::CM) | ||