diff options
Diffstat (limited to 'packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs')
-rw-r--r-- | packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs index 7c54535..4704989 100644 --- a/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs +++ b/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs | |||
@@ -14,7 +14,7 @@ Arbitrary instances for vectors, matrices. | |||
14 | module Numeric.LinearAlgebra.Tests.Instances( | 14 | module Numeric.LinearAlgebra.Tests.Instances( |
15 | Sq(..), rSq,cSq, | 15 | Sq(..), rSq,cSq, |
16 | Rot(..), rRot,cRot, | 16 | Rot(..), rRot,cRot, |
17 | Her(..), rHer,cHer, | 17 | rHer,cHer, |
18 | WC(..), rWC,cWC, | 18 | WC(..), rWC,cWC, |
19 | SqWC(..), rSqWC, cSqWC, rSymWC, cSymWC, | 19 | SqWC(..), rSqWC, cSqWC, rSymWC, cSymWC, |
20 | PosDef(..), rPosDef, cPosDef, | 20 | PosDef(..), rPosDef, cPosDef, |
@@ -81,12 +81,12 @@ instance (Field a, Arbitrary a) => Arbitrary (Rot a) where | |||
81 | 81 | ||
82 | 82 | ||
83 | -- a complex hermitian or real symmetric matrix | 83 | -- a complex hermitian or real symmetric matrix |
84 | newtype (Her a) = Her (Matrix a) deriving Show | 84 | --newtype (Her a) = Her (Matrix a) deriving Show |
85 | instance (Field a, Arbitrary a, Num (Vector a)) => Arbitrary (Her a) where | 85 | instance (Field a, Arbitrary a, Num (Vector a)) => Arbitrary (Her a) where |
86 | arbitrary = do | 86 | arbitrary = do |
87 | Sq m <- arbitrary | 87 | Sq m <- arbitrary |
88 | let m' = m/2 | 88 | let m' = m/2 |
89 | return $ Her (m' + tr m') | 89 | return $ sym m' |
90 | 90 | ||
91 | 91 | ||
92 | class (Field a, Arbitrary a, Element (RealOf a), Random (RealOf a)) => ArbitraryField a | 92 | class (Field a, Arbitrary a, Element (RealOf a), Random (RealOf a)) => ArbitraryField a |
@@ -125,9 +125,9 @@ newtype (PosDef a) = PosDef (Matrix a) deriving Show | |||
125 | instance (Numeric a, ArbitraryField a, Num (Vector a)) | 125 | instance (Numeric a, ArbitraryField a, Num (Vector a)) |
126 | => Arbitrary (PosDef a) where | 126 | => Arbitrary (PosDef a) where |
127 | arbitrary = do | 127 | arbitrary = do |
128 | Her m <- arbitrary | 128 | m <- arbitrary |
129 | let (_,v) = eigSH m | 129 | let (_,v) = eigSH m |
130 | n = rows m | 130 | n = rows (her m) |
131 | l <- replicateM n (choose (0,100)) | 131 | l <- replicateM n (choose (0,100)) |
132 | let s = diag (fromList l) | 132 | let s = diag (fromList l) |
133 | p = v <> real s <> tr v | 133 | p = v <> real s <> tr v |
@@ -161,8 +161,8 @@ fM m = m :: FM | |||
161 | zM m = m :: ZM | 161 | zM m = m :: ZM |
162 | 162 | ||
163 | 163 | ||
164 | rHer (Her m) = m :: RM | 164 | rHer m = her m :: RM |
165 | cHer (Her m) = m :: CM | 165 | cHer m = her m :: CM |
166 | 166 | ||
167 | rRot (Rot m) = m :: RM | 167 | rRot (Rot m) = m :: RM |
168 | cRot (Rot m) = m :: CM | 168 | cRot (Rot m) = m :: CM |
@@ -176,8 +176,8 @@ cWC (WC m) = m :: CM | |||
176 | rSqWC (SqWC m) = m :: RM | 176 | rSqWC (SqWC m) = m :: RM |
177 | cSqWC (SqWC m) = m :: CM | 177 | cSqWC (SqWC m) = m :: CM |
178 | 178 | ||
179 | rSymWC (SqWC m) = m + tr m :: RM | 179 | rSymWC (SqWC m) = sym m :: Her R |
180 | cSymWC (SqWC m) = m + tr m :: CM | 180 | cSymWC (SqWC m) = sym m :: Her C |
181 | 181 | ||
182 | rPosDef (PosDef m) = m :: RM | 182 | rPosDef (PosDef m) = m :: RM |
183 | cPosDef (PosDef m) = m :: CM | 183 | cPosDef (PosDef m) = m :: CM |