summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Tests/Properties.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2009-12-29 12:30:59 +0000
committerAlberto Ruiz <aruiz@um.es>2009-12-29 12:30:59 +0000
commit036f0f19c473cb58a1f7330a481d0e8f705ac452 (patch)
tree7deb0e6b41b5b74bb8f5aca3e23d1dca8a57cfb7 /lib/Numeric/LinearAlgebra/Tests/Properties.hs
parent3d15dffe52629fd621ad548b671c3043caefb0d0 (diff)
linearSolveLS, rq
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Tests/Properties.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Tests/Properties.hs22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
index 7bb914f..405ce64 100644
--- a/lib/Numeric/LinearAlgebra/Tests/Properties.hs
+++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
@@ -32,13 +32,13 @@ module Numeric.LinearAlgebra.Tests.Properties (
32 svdProp1, svdProp1a, svdProp2, svdProp3, svdProp4, 32 svdProp1, svdProp1a, svdProp2, svdProp3, svdProp4,
33 svdProp5a, svdProp5b, svdProp6a, svdProp6b, svdProp7, 33 svdProp5a, svdProp5b, svdProp6a, svdProp6b, svdProp7,
34 eigProp, eigSHProp, eigProp2, eigSHProp2, 34 eigProp, eigSHProp, eigProp2, eigSHProp2,
35 qrProp, 35 qrProp, rqProp,
36 hessProp, 36 hessProp,
37 schurProp1, schurProp2, 37 schurProp1, schurProp2,
38 cholProp, 38 cholProp,
39 expmDiagProp, 39 expmDiagProp,
40 multProp1, multProp2, 40 multProp1, multProp2,
41 linearSolveProp 41 linearSolveProp, linearSolveProp2
42) where 42) where
43 43
44import Numeric.LinearAlgebra 44import Numeric.LinearAlgebra
@@ -177,10 +177,11 @@ svdProp6b m = s |~| s' && v |~| v' && s |~| s'' && u |~| u'
177 (s',v') = rightSVC m 177 (s',v') = rightSVC m
178 (u',s'') = leftSVC m 178 (u',s'') = leftSVC m
179 179
180svdProp7 m = s |~| s' && u |~| u' && v |~| v' 180svdProp7 m = s |~| s' && u |~| u' && v |~| v' && s |~| s'''
181 where (u,s,v) = svd m 181 where (u,s,v) = svd m
182 (s',v') = rightSV m 182 (s',v') = rightSV m
183 (u',s'') = leftSV m 183 (u',s'') = leftSV m
184 s''' = singularValues m
184 185
185------------------------------------------------------------------ 186------------------------------------------------------------------
186 187
@@ -201,6 +202,16 @@ eigSHProp2 m = fst (eigSH m) |~| eigenvaluesSH m
201qrProp m = q <> r |~| m && unitary q && upperTriang r 202qrProp m = q <> r |~| m && unitary q && upperTriang r
202 where (q,r) = qr m 203 where (q,r) = qr m
203 204
205rqProp m = r <> q |~| m && unitary q && utr
206 where (r,q) = rq m
207 upptr f c = buildMatrix f c $ \(r',c') -> if r'-t > c' then 0 else 1
208 where t = f-c
209 utr = upptr (rows r) (cols r) * r |~| r
210
211upperTriang' m = rows m == 1 || down |~| z
212 where down = fromList $ concat $ zipWith drop [1..] (toLists (ctrans m))
213 z = constant 0 (dim down)
214
204hessProp m = m |~| p <> h <> ctrans p && unitary p && upperHessenberg h 215hessProp m = m |~| p <> h <> ctrans p && unitary p && upperHessenberg h
205 where (p,h) = hess m 216 where (p,h) = hess m
206 217
@@ -226,3 +237,8 @@ multProp1 (a,b) = a <> b |~| mulH a b
226multProp2 (a,b) = ctrans (a <> b) |~| ctrans b <> ctrans a 237multProp2 (a,b) = ctrans (a <> b) |~| ctrans b <> ctrans a
227 238
228linearSolveProp f m = f m m |~| ident (rows m) 239linearSolveProp f m = f m m |~| ident (rows m)
240
241linearSolveProp2 f (a,x) = not wc `trivial` (not wc || a <> f a b |~| b)
242 where q = min (rows a) (cols a)
243 b = a <> x
244 wc = rank a == q