summaryrefslogtreecommitdiff
path: root/packages/tests/src/Numeric/LinearAlgebra/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tests/src/Numeric/LinearAlgebra/Tests')
-rw-r--r--packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs91
-rw-r--r--packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs153
2 files changed, 92 insertions, 152 deletions
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs
index 53fc4d2..904ae05 100644
--- a/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs
+++ b/packages/tests/src/Numeric/LinearAlgebra/Tests/Instances.hs
@@ -1,5 +1,4 @@
1{-# LANGUAGE FlexibleContexts, UndecidableInstances, CPP, FlexibleInstances #-} 1{-# LANGUAGE FlexibleContexts, UndecidableInstances, FlexibleInstances #-}
2{-# OPTIONS_GHC -fno-warn-unused-imports #-}
3----------------------------------------------------------------------------- 2-----------------------------------------------------------------------------
4{- | 3{- |
5Module : Numeric.LinearAlgebra.Tests.Instances 4Module : Numeric.LinearAlgebra.Tests.Instances
@@ -26,15 +25,11 @@ module Numeric.LinearAlgebra.Tests.Instances(
26 25
27import System.Random 26import System.Random
28 27
29import Numeric.LinearAlgebra 28import Numeric.LinearAlgebra.HMatrix hiding (vector)
30import Numeric.LinearAlgebra.Devel
31import Numeric.Container
32import Control.Monad(replicateM) 29import Control.Monad(replicateM)
33import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector 30import Test.QuickCheck(Arbitrary,arbitrary,choose,vector,sized,shrink)
34 ,sized,classify,Testable,Property 31
35 ,quickCheckWith,maxSize,stdArgs,shrink)
36 32
37#if MIN_VERSION_QuickCheck(2,0,0)
38shrinkListElementwise :: (Arbitrary a) => [a] -> [[a]] 33shrinkListElementwise :: (Arbitrary a) => [a] -> [[a]]
39shrinkListElementwise [] = [] 34shrinkListElementwise [] = []
40shrinkListElementwise (x:xs) = [ y:xs | y <- shrink x ] 35shrinkListElementwise (x:xs) = [ y:xs | y <- shrink x ]
@@ -42,25 +37,6 @@ shrinkListElementwise (x:xs) = [ y:xs | y <- shrink x ]
42 37
43shrinkPair :: (Arbitrary a, Arbitrary b) => (a,b) -> [(a,b)] 38shrinkPair :: (Arbitrary a, Arbitrary b) => (a,b) -> [(a,b)]
44shrinkPair (a,b) = [ (a,x) | x <- shrink b ] ++ [ (x,b) | x <- shrink a ] 39shrinkPair (a,b) = [ (a,x) | x <- shrink b ] ++ [ (x,b) | x <- shrink a ]
45#endif
46
47#if MIN_VERSION_QuickCheck(2,1,1)
48#else
49instance (Arbitrary a, RealFloat a) => Arbitrary (Complex a) where
50 arbitrary = do
51 re <- arbitrary
52 im <- arbitrary
53 return (re :+ im)
54
55#if MIN_VERSION_QuickCheck(2,0,0)
56 shrink (re :+ im) =
57 [ u :+ v | (u,v) <- shrinkPair (re,im) ]
58#else
59 -- this has been moved to the 'Coarbitrary' class in QuickCheck 2
60 coarbitrary = undefined
61#endif
62
63#endif
64 40
65chooseDim = sized $ \m -> choose (1,max 1 m) 41chooseDim = sized $ \m -> choose (1,max 1 m)
66 42
@@ -68,15 +44,9 @@ instance (Field a, Arbitrary a) => Arbitrary (Vector a) where
68 arbitrary = do m <- chooseDim 44 arbitrary = do m <- chooseDim
69 l <- vector m 45 l <- vector m
70 return $ fromList l 46 return $ fromList l
71
72#if MIN_VERSION_QuickCheck(2,0,0)
73 -- shrink any one of the components 47 -- shrink any one of the components
74 shrink = map fromList . shrinkListElementwise . toList 48 shrink = map fromList . shrinkListElementwise . toList
75 49
76#else
77 coarbitrary = undefined
78#endif
79
80instance (Element a, Arbitrary a) => Arbitrary (Matrix a) where 50instance (Element a, Arbitrary a) => Arbitrary (Matrix a) where
81 arbitrary = do 51 arbitrary = do
82 m <- chooseDim 52 m <- chooseDim
@@ -84,16 +54,11 @@ instance (Element a, Arbitrary a) => Arbitrary (Matrix a) where
84 l <- vector (m*n) 54 l <- vector (m*n)
85 return $ (m><n) l 55 return $ (m><n) l
86 56
87#if MIN_VERSION_QuickCheck(2,0,0)
88 -- shrink any one of the components 57 -- shrink any one of the components
89 shrink a = map (rows a >< cols a) 58 shrink a = map (rows a >< cols a)
90 . shrinkListElementwise 59 . shrinkListElementwise
91 . concat . toLists 60 . concat . toLists
92 $ a 61 $ a
93#else
94 coarbitrary = undefined
95#endif
96
97 62
98-- a square matrix 63-- a square matrix
99newtype (Sq a) = Sq (Matrix a) deriving Show 64newtype (Sq a) = Sq (Matrix a) deriving Show
@@ -103,11 +68,7 @@ instance (Element a, Arbitrary a) => Arbitrary (Sq a) where
103 l <- vector (n*n) 68 l <- vector (n*n)
104 return $ Sq $ (n><n) l 69 return $ Sq $ (n><n) l
105 70
106#if MIN_VERSION_QuickCheck(2,0,0)
107 shrink (Sq a) = [ Sq b | b <- shrink a ] 71 shrink (Sq a) = [ Sq b | b <- shrink a ]
108#else
109 coarbitrary = undefined
110#endif
111 72
112 73
113-- a unitary matrix 74-- a unitary matrix
@@ -118,11 +79,6 @@ instance (Field a, Arbitrary a) => Arbitrary (Rot a) where
118 let (q,_) = qr m 79 let (q,_) = qr m
119 return (Rot q) 80 return (Rot q)
120 81
121#if MIN_VERSION_QuickCheck(2,0,0)
122#else
123 coarbitrary = undefined
124#endif
125
126 82
127-- a complex hermitian or real symmetric matrix 83-- a complex hermitian or real symmetric matrix
128newtype (Her a) = Her (Matrix a) deriving Show 84newtype (Her a) = Her (Matrix a) deriving Show
@@ -130,12 +86,8 @@ instance (Field a, Arbitrary a, Num (Vector a)) => Arbitrary (Her a) where
130 arbitrary = do 86 arbitrary = do
131 Sq m <- arbitrary 87 Sq m <- arbitrary
132 let m' = m/2 88 let m' = m/2
133 return $ Her (m' + ctrans m') 89 return $ Her (m' + tr m')
134 90
135#if MIN_VERSION_QuickCheck(2,0,0)
136#else
137 coarbitrary = undefined
138#endif
139 91
140class (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
141instance ArbitraryField Double 93instance ArbitraryField Double
@@ -144,7 +96,7 @@ instance ArbitraryField (Complex Double)
144 96
145-- a well-conditioned general matrix (the singular values are between 1 and 100) 97-- a well-conditioned general matrix (the singular values are between 1 and 100)
146newtype (WC a) = WC (Matrix a) deriving Show 98newtype (WC a) = WC (Matrix a) deriving Show
147instance (ArbitraryField a) => Arbitrary (WC a) where 99instance (Numeric a, ArbitraryField a) => Arbitrary (WC a) where
148 arbitrary = do 100 arbitrary = do
149 m <- arbitrary 101 m <- arbitrary
150 let (u,_,v) = svd m 102 let (u,_,v) = svd m
@@ -153,34 +105,24 @@ instance (ArbitraryField a) => Arbitrary (WC a) where
153 n = min r c 105 n = min r c
154 sv' <- replicateM n (choose (1,100)) 106 sv' <- replicateM n (choose (1,100))
155 let s = diagRect 0 (fromList sv') r c 107 let s = diagRect 0 (fromList sv') r c
156 return $ WC (u `mXm` real s `mXm` trans v) 108 return $ WC (u <> real s <> tr v)
157
158#if MIN_VERSION_QuickCheck(2,0,0)
159#else
160 coarbitrary = undefined
161#endif
162 109
163 110
164-- a well-conditioned square matrix (the singular values are between 1 and 100) 111-- a well-conditioned square matrix (the singular values are between 1 and 100)
165newtype (SqWC a) = SqWC (Matrix a) deriving Show 112newtype (SqWC a) = SqWC (Matrix a) deriving Show
166instance (ArbitraryField a) => Arbitrary (SqWC a) where 113instance (ArbitraryField a, Numeric a) => Arbitrary (SqWC a) where
167 arbitrary = do 114 arbitrary = do
168 Sq m <- arbitrary 115 Sq m <- arbitrary
169 let (u,_,v) = svd m 116 let (u,_,v) = svd m
170 n = rows m 117 n = rows m
171 sv' <- replicateM n (choose (1,100)) 118 sv' <- replicateM n (choose (1,100))
172 let s = diag (fromList sv') 119 let s = diag (fromList sv')
173 return $ SqWC (u `mXm` real s `mXm` trans v) 120 return $ SqWC (u <> real s <> tr v)
174
175#if MIN_VERSION_QuickCheck(2,0,0)
176#else
177 coarbitrary = undefined
178#endif
179 121
180 122
181-- a positive definite square matrix (the eigenvalues are between 0 and 100) 123-- a positive definite square matrix (the eigenvalues are between 0 and 100)
182newtype (PosDef a) = PosDef (Matrix a) deriving Show 124newtype (PosDef a) = PosDef (Matrix a) deriving Show
183instance (ArbitraryField a, Num (Vector a)) 125instance (Numeric a, ArbitraryField a, Num (Vector a))
184 => Arbitrary (PosDef a) where 126 => Arbitrary (PosDef a) where
185 arbitrary = do 127 arbitrary = do
186 Her m <- arbitrary 128 Her m <- arbitrary
@@ -188,13 +130,8 @@ instance (ArbitraryField a, Num (Vector a))
188 n = rows m 130 n = rows m
189 l <- replicateM n (choose (0,100)) 131 l <- replicateM n (choose (0,100))
190 let s = diag (fromList l) 132 let s = diag (fromList l)
191 p = v `mXm` real s `mXm` ctrans v 133 p = v <> real s <> tr v
192 return $ PosDef (0.5 * p + 0.5 * ctrans p) 134 return $ PosDef (0.5 * p + 0.5 * tr p)
193
194#if MIN_VERSION_QuickCheck(2,0,0)
195#else
196 coarbitrary = undefined
197#endif
198 135
199 136
200-- a pair of matrices that can be multiplied 137-- a pair of matrices that can be multiplied
@@ -208,11 +145,7 @@ instance (Field a, Arbitrary a) => Arbitrary (Consistent a) where
208 lb <- vector (k*m) 145 lb <- vector (k*m)
209 return $ Consistent ((n><k) la, (k><m) lb) 146 return $ Consistent ((n><k) la, (k><m) lb)
210 147
211#if MIN_VERSION_QuickCheck(2,0,0)
212 shrink (Consistent (x,y)) = [ Consistent (u,v) | (u,v) <- shrinkPair (x,y) ] 148 shrink (Consistent (x,y)) = [ Consistent (u,v) | (u,v) <- shrinkPair (x,y) ]
213#else
214 coarbitrary = undefined
215#endif
216 149
217 150
218 151
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs
index a5c37f4..207a303 100644
--- a/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs
+++ b/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs
@@ -1,5 +1,4 @@
1{-# LANGUAGE CPP, FlexibleContexts #-} 1{-# LANGUAGE FlexibleContexts #-}
2{-# OPTIONS_GHC -fno-warn-unused-imports #-}
3{-# LANGUAGE TypeFamilies #-} 2{-# LANGUAGE TypeFamilies #-}
4 3
5----------------------------------------------------------------------------- 4-----------------------------------------------------------------------------
@@ -29,7 +28,7 @@ module Numeric.LinearAlgebra.Tests.Properties (
29 pinvProp, 28 pinvProp,
30 detProp, 29 detProp,
31 nullspaceProp, 30 nullspaceProp,
32 bugProp, 31-- bugProp,
33 svdProp1, svdProp1a, svdProp1b, svdProp2, svdProp3, svdProp4, 32 svdProp1, svdProp1a, svdProp1b, svdProp2, svdProp3, svdProp4,
34 svdProp5a, svdProp5b, svdProp6a, svdProp6b, svdProp7, 33 svdProp5a, svdProp5b, svdProp6a, svdProp6b, svdProp7,
35 eigProp, eigSHProp, eigProp2, eigSHProp2, 34 eigProp, eigSHProp, eigProp2, eigSHProp2,
@@ -43,20 +42,15 @@ module Numeric.LinearAlgebra.Tests.Properties (
43 linearSolveProp, linearSolveProp2 42 linearSolveProp, linearSolveProp2
44) where 43) where
45 44
46import Numeric.Container 45import Numeric.LinearAlgebra.HMatrix hiding (Testable,unitary)
47import Numeric.LinearAlgebra --hiding (real,complex) 46import Test.QuickCheck
48import Numeric.LinearAlgebra.LAPACK
49import Debug.Trace
50import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector
51 ,sized,classify,Testable,Property
52 ,quickCheckWith,maxSize,stdArgs,shrink)
53 47
54trivial :: Testable a => Bool -> a -> Property 48trivial :: Testable a => Bool -> a -> Property
55trivial = (`classify` "trivial") 49trivial = (`classify` "trivial")
56 50
57-- relative error 51-- relative error
58dist :: (Normed c t, Num (c t)) => c t -> c t -> Double 52dist :: (Num a, Normed a) => a -> a -> Double
59dist = relativeError Infinity 53dist = relativeError norm_Inf
60 54
61infixl 4 |~| 55infixl 4 |~|
62a |~| b = a :~10~: b 56a |~| b = a :~10~: b
@@ -73,11 +67,11 @@ a :~n~: b = dist a b < 10^^(-n)
73square m = rows m == cols m 67square m = rows m == cols m
74 68
75-- orthonormal columns 69-- orthonormal columns
76orthonormal m = ctrans m <> m |~| ident (cols m) 70orthonormal m = tr m <> m |~| ident (cols m)
77 71
78unitary m = square m && orthonormal m 72unitary m = square m && orthonormal m
79 73
80hermitian m = square m && m |~| ctrans m 74hermitian m = square m && m |~| tr m
81 75
82wellCond m = rcond m > 1/100 76wellCond m = rcond m > 1/100
83 77
@@ -85,12 +79,12 @@ positiveDefinite m = minimum (toList e) > 0
85 where (e,_v) = eigSH m 79 where (e,_v) = eigSH m
86 80
87upperTriang m = rows m == 1 || down == z 81upperTriang m = rows m == 1 || down == z
88 where down = fromList $ concat $ zipWith drop [1..] (toLists (ctrans m)) 82 where down = fromList $ concat $ zipWith drop [1..] (toLists (tr m))
89 z = konst 0 (dim down) 83 z = konst 0 (size down)
90 84
91upperHessenberg m = rows m < 3 || down == z 85upperHessenberg m = rows m < 3 || down == z
92 where down = fromList $ concat $ zipWith drop [2..] (toLists (ctrans m)) 86 where down = fromList $ concat $ zipWith drop [2..] (toLists (tr m))
93 z = konst 0 (dim down) 87 z = konst 0 (size down)
94 88
95zeros (r,c) = reshape c (konst 0 (r*c)) 89zeros (r,c) = reshape c (konst 0 (r*c))
96 90
@@ -118,81 +112,94 @@ detProp m = s d1 |~| s d2
118 s x = fromList [x] 112 s x = fromList [x]
119 113
120nullspaceProp m = null nl `trivial` (null nl || m <> n |~| zeros (r,c) 114nullspaceProp m = null nl `trivial` (null nl || m <> n |~| zeros (r,c)
121 && orthonormal (fromColumns nl)) 115 && orthonormal n)
122 where nl = nullspacePrec 1 m 116 where n = nullspaceSVD (Left (1*peps)) m (rightSV m)
123 n = fromColumns nl 117 nl = toColumns n
124 r = rows m 118 r = rows m
125 c = cols m - rank m 119 c = cols m - rank m
126 120
127------------------------------------------------------------------ 121------------------------------------------------------------------
128 122{-
129-- testcase for nonempty fpu stack 123-- testcase for nonempty fpu stack
130-- uncommenting unitary' signature eliminates the problem 124-- uncommenting unitary' signature eliminates the problem
131bugProp m = m |~| u <> real d <> trans v && unitary' u && unitary' v 125bugProp m = m |~| u <> real d <> tr v && unitary' u && unitary' v
132 where (u,d,v) = fullSVD m 126 where (u,d,v) = svd m
133 -- unitary' :: (Num (Vector t), Field t) => Matrix t -> Bool 127 -- unitary' :: (Num (Vector t), Field t) => Matrix t -> Bool
134 unitary' a = unitary a 128 unitary' a = unitary a
135 129-}
136------------------------------------------------------------------ 130------------------------------------------------------------------
137 131
138-- fullSVD 132-- fullSVD
139svdProp1 m = m |~| u <> real d <> trans v && unitary u && unitary v 133svdProp1 m = m |~| u <> real d <> tr v && unitary u && unitary v
140 where (u,d,v) = fullSVD m 134 where
135 (u,s,v) = svd m
136 d = diagRect 0 s (rows m) (cols m)
141 137
142svdProp1a svdfun m = m |~| u <> real d <> trans v && unitary u && unitary v where 138svdProp1a svdfun m = m |~| u <> real d <> tr v && unitary u && unitary v
139 where
143 (u,s,v) = svdfun m 140 (u,s,v) = svdfun m
144 d = diagRect 0 s (rows m) (cols m) 141 d = diagRect 0 s (rows m) (cols m)
145 142
146svdProp1b svdfun m = unitary u && unitary v where 143svdProp1b svdfun m = unitary u && unitary v
144 where
147 (u,_,v) = svdfun m 145 (u,_,v) = svdfun m
148 146
149-- thinSVD 147-- thinSVD
150svdProp2 thinSVDfun m = m |~| u <> diag (real s) <> trans v && orthonormal u && orthonormal v && dim s == min (rows m) (cols m) 148svdProp2 thinSVDfun m
151 where (u,s,v) = thinSVDfun m 149 = m |~| u <> diag (real s) <> tr v
150 && orthonormal u && orthonormal v
151 && size s == min (rows m) (cols m)
152 where
153 (u,s,v) = thinSVDfun m
152 154
153-- compactSVD 155-- compactSVD
154svdProp3 m = (m |~| u <> real (diag s) <> trans v 156svdProp3 m = (m |~| u <> real (diag s) <> tr v
155 && orthonormal u && orthonormal v) 157 && orthonormal u && orthonormal v)
156 where (u,s,v) = compactSVD m 158 where
159 (u,s,v) = compactSVD m
157 160
158svdProp4 m' = m |~| u <> real (diag s) <> trans v 161svdProp4 m' = m |~| u <> real (diag s) <> tr v
159 && orthonormal u && orthonormal v 162 && orthonormal u && orthonormal v
160 && (dim s == r || r == 0 && dim s == 1) 163 && (size s == r || r == 0 && size s == 1)
161 where (u,s,v) = compactSVD m 164 where
162 m = fromBlocks [[m'],[m']] 165 (u,s,v) = compactSVD m
163 r = rank m' 166 m = fromBlocks [[m'],[m']]
164 167 r = rank m'
165svdProp5a m = all (s1|~|) [s2,s3,s4,s5,s6] where 168
166 s1 = svR m 169svdProp5a m = all (s1|~|) [s3,s5] where
167 s2 = svRd m 170 s1 = singularValues (m :: Matrix Double)
168 (_,s3,_) = svdR m 171-- s2 = svRd m
169 (_,s4,_) = svdRd m 172 (_,s3,_) = svd m
170 (_,s5,_) = thinSVDR m 173-- (_,s4,_) = svdRd m
171 (_,s6,_) = thinSVDRd m 174 (_,s5,_) = thinSVD m
172 175-- (_,s6,_) = thinSVDRd m
173svdProp5b m = all (s1|~|) [s2,s3,s4,s5,s6] where 176
174 s1 = svC m 177svdProp5b m = all (s1|~|) [s3,s5] where
175 s2 = svCd m 178 s1 = singularValues (m :: Matrix (Complex Double))
176 (_,s3,_) = svdC m 179-- s2 = svCd m
177 (_,s4,_) = svdCd m 180 (_,s3,_) = svd m
178 (_,s5,_) = thinSVDC m 181-- (_,s4,_) = svdCd m
179 (_,s6,_) = thinSVDCd m 182 (_,s5,_) = thinSVD m
183-- (_,s6,_) = thinSVDCd m
180 184
181svdProp6a m = s |~| s' && v |~| v' && s |~| s'' && u |~| u' 185svdProp6a m = s |~| s' && v |~| v' && s |~| s'' && u |~| u'
182 where (u,s,v) = svdR m 186 where
183 (s',v') = rightSVR m 187 (u,s,v) = svd (m :: Matrix Double)
184 (u',s'') = leftSVR m 188 (s',v') = rightSV m
189 (u',s'') = leftSV m
185 190
186svdProp6b m = s |~| s' && v |~| v' && s |~| s'' && u |~| u' 191svdProp6b m = s |~| s' && v |~| v' && s |~| s'' && u |~| u'
187 where (u,s,v) = svdC m 192 where
188 (s',v') = rightSVC m 193 (u,s,v) = svd (m :: Matrix (Complex Double))
189 (u',s'') = leftSVC m 194 (s',v') = rightSV m
195 (u',s'') = leftSV m
190 196
191svdProp7 m = s |~| s' && u |~| u' && v |~| v' && s |~| s''' 197svdProp7 m = s |~| s' && u |~| u' && v |~| v' && s |~| s'''
192 where (u,s,v) = svd m 198 where
193 (s',v') = rightSV m 199 (u,s,v) = svd m
194 (u',_s'') = leftSV m 200 (s',v') = rightSV m
195 s''' = singularValues m 201 (u',_s'') = leftSV m
202 s''' = singularValues m
196 203
197------------------------------------------------------------------ 204------------------------------------------------------------------
198 205
@@ -201,7 +208,7 @@ eigProp m = complex m <> v |~| v <> diag s
201 208
202eigSHProp m = m <> v |~| v <> real (diag s) 209eigSHProp m = m <> v |~| v <> real (diag s)
203 && unitary v 210 && unitary v
204 && m |~| v <> real (diag s) <> ctrans v 211 && m |~| v <> real (diag s) <> tr v
205 where (s, v) = eigSH m 212 where (s, v) = eigSH m
206 213
207eigProp2 m = fst (eig m) |~| eigenvalues m 214eigProp2 m = fst (eig m) |~| eigenvalues m
@@ -226,19 +233,19 @@ rqProp3 m = upperTriang' r
226 where (r,_q) = rq m 233 where (r,_q) = rq m
227 234
228upperTriang' r = upptr (rows r) (cols r) * r |~| r 235upperTriang' r = upptr (rows r) (cols r) * r |~| r
229 where upptr f c = buildMatrix f c $ \(r',c') -> if r'-t > c' then 0 else 1 236 where upptr f c = build (f,c) $ \r' c' -> if r'-t > c' then 0 else 1
230 where t = f-c 237 where t = fromIntegral (f-c)
231 238
232hessProp m = m |~| p <> h <> ctrans p && unitary p && upperHessenberg h 239hessProp m = m |~| p <> h <> tr p && unitary p && upperHessenberg h
233 where (p,h) = hess m 240 where (p,h) = hess m
234 241
235schurProp1 m = m |~| u <> s <> ctrans u && unitary u && upperTriang s 242schurProp1 m = m |~| u <> s <> tr u && unitary u && upperTriang s
236 where (u,s) = schur m 243 where (u,s) = schur m
237 244
238schurProp2 m = m |~| u <> s <> ctrans u && unitary u && upperHessenberg s -- fixme 245schurProp2 m = m |~| u <> s <> tr u && unitary u && upperHessenberg s -- fixme
239 where (u,s) = schur m 246 where (u,s) = schur m
240 247
241cholProp m = m |~| ctrans c <> c && upperTriang c 248cholProp m = m |~| tr c <> c && upperTriang c
242 where c = chol m 249 where c = chol m
243 250
244exactProp m = chol m == chol (m+0) 251exactProp m = chol m == chol (m+0)
@@ -252,7 +259,7 @@ mulH a b = fromLists [[ doth ai bj | bj <- toColumns b] | ai <- toRows a ]
252 259
253multProp1 p (a,b) = (a <> b) :~p~: (mulH a b) 260multProp1 p (a,b) = (a <> b) :~p~: (mulH a b)
254 261
255multProp2 p (a,b) = (ctrans (a <> b)) :~p~: (ctrans b <> ctrans a) 262multProp2 p (a,b) = (tr (a <> b)) :~p~: (tr b <> tr a)
256 263
257linearSolveProp f m = f m m |~| ident (rows m) 264linearSolveProp f m = f m m |~| ident (rows m)
258 265
@@ -261,5 +268,5 @@ linearSolveProp2 f (a,x) = not wc `trivial` (not wc || a <> f a b |~| b)
261 b = a <> x 268 b = a <> x
262 wc = rank a == q 269 wc = rank a == q
263 270
264subProp m = m == (trans . fromColumns . toRows) m 271subProp m = m == (conj . tr . fromColumns . toRows) m
265 272