summaryrefslogtreecommitdiff
path: root/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs')
-rw-r--r--packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs18
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.
14module Numeric.LinearAlgebra.Tests.Instances( 14module 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
84newtype (Her a) = Her (Matrix a) deriving Show 84--newtype (Her a) = Her (Matrix a) deriving Show
85instance (Field a, Arbitrary a, Num (Vector a)) => Arbitrary (Her a) where 85instance (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
92class (Field a, Arbitrary a, Element (RealOf a), Random (RealOf a)) => ArbitraryField a 92class (Field a, Arbitrary a, Element (RealOf a), Random (RealOf a)) => ArbitraryField a
@@ -125,9 +125,9 @@ newtype (PosDef a) = PosDef (Matrix a) deriving Show
125instance (Numeric a, ArbitraryField a, Num (Vector a)) 125instance (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
161zM m = m :: ZM 161zM m = m :: ZM
162 162
163 163
164rHer (Her m) = m :: RM 164rHer m = her m :: RM
165cHer (Her m) = m :: CM 165cHer m = her m :: CM
166 166
167rRot (Rot m) = m :: RM 167rRot (Rot m) = m :: RM
168cRot (Rot m) = m :: CM 168cRot (Rot m) = m :: CM
@@ -176,8 +176,8 @@ cWC (WC m) = m :: CM
176rSqWC (SqWC m) = m :: RM 176rSqWC (SqWC m) = m :: RM
177cSqWC (SqWC m) = m :: CM 177cSqWC (SqWC m) = m :: CM
178 178
179rSymWC (SqWC m) = m + tr m :: RM 179rSymWC (SqWC m) = sym m :: Her R
180cSymWC (SqWC m) = m + tr m :: CM 180cSymWC (SqWC m) = sym m :: Her C
181 181
182rPosDef (PosDef m) = m :: RM 182rPosDef (PosDef m) = m :: RM
183cPosDef (PosDef m) = m :: CM 183cPosDef (PosDef m) = m :: CM