summaryrefslogtreecommitdiff
path: root/examples/tests.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tests.hs')
-rw-r--r--examples/tests.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/tests.hs b/examples/tests.hs
index 0a09ced..2f3b3d8 100644
--- a/examples/tests.hs
+++ b/examples/tests.hs
@@ -6,10 +6,9 @@
6 6
7----------------------------------------------------------------------------- 7-----------------------------------------------------------------------------
8 8
9import Data.Packed.Internal 9import Data.Packed.Internal((>|<), fdat, cdat, multiply', multiplyG, MatrixOrder(..))
10import Data.Packed.Vector 10import Data.Packed.Vector
11import Data.Packed.Matrix 11import Data.Packed.Matrix
12import Data.Packed.Internal.Matrix
13import GSL.Vector 12import GSL.Vector
14import GSL.Integration 13import GSL.Integration
15import GSL.Differentiation 14import GSL.Differentiation
@@ -95,6 +94,8 @@ asC m = (rows m >< cols m) $ toList (cdat m)
95mulC a b = multiply' RowMajor a b 94mulC a b = multiply' RowMajor a b
96mulF a b = multiply' ColumnMajor a b 95mulF a b = multiply' ColumnMajor a b
97 96
97identC = comp . ident
98
98infixl 7 <> 99infixl 7 <>
99a <> b = mulF a b 100a <> b = mulF a b
100 101
@@ -198,15 +199,15 @@ svdTestR fun m = u <> s <> trans v |~| m
198 199
199 200
200svdTestC m = u <> s' <> (trans v) |~| m 201svdTestC m = u <> s' <> (trans v) |~| m
201 && u <> conjTrans u |~| ident (rows m) 202 && u <> conjTrans u |~| identC (rows m)
202 && v <> conjTrans v |~| ident (cols m) 203 && v <> conjTrans v |~| identC (cols m)
203 where (u,s,v) = svdC m 204 where (u,s,v) = svdC m
204 s' = liftMatrix comp s 205 s' = liftMatrix comp s
205 206
206--svdg' m = (u,s',v) where 207--svdg' m = (u,s',v) where
207 208
208eigTestC (SqM m) = (m <> v) |~| (v <> diag s) 209eigTestC (SqM m) = (m <> v) |~| (v <> diag s)
209 && takeDiag (conjTrans v <> v) |~| constant 1 (rows m) --normalized 210 && takeDiag (conjTrans v <> v) |~| comp (constant 1 (rows m)) --normalized
210 where (s,v) = eigC m 211 where (s,v) = eigC m
211 212
212eigTestR (SqM m) = (liftMatrix comp m <> v) |~| (v <> diag s) 213eigTestR (SqM m) = (liftMatrix comp m <> v) |~| (v <> diag s)
@@ -218,7 +219,7 @@ eigTestS (Sym m) = (m <> v) |~| (v <> diag s)
218 where (s,v) = eigS m 219 where (s,v) = eigS m
219 220
220eigTestH (Her m) = (m <> v) |~| (v <> diag (comp s)) 221eigTestH (Her m) = (m <> v) |~| (v <> diag (comp s))
221 && v <> conjTrans v |~| ident (cols m) 222 && v <> conjTrans v |~| identC (cols m)
222 where (s,v) = eigH m 223 where (s,v) = eigH m
223 224
224linearSolveSQTest fun singu (PairSM a b) = singu a || (a <> fun a b) |~| b 225linearSolveSQTest fun singu (PairSM a b) = singu a || (a <> fun a b) |~| b
@@ -248,11 +249,11 @@ identC n = toComplex(ident n, (0::Double) <>ident n)
248pinvTest f m = (m <> f m <> m) |~| m 249pinvTest f m = (m <> f m <> m) |~| m
249 250
250pinvR m = linearSolveLSR m (ident (rows m)) 251pinvR m = linearSolveLSR m (ident (rows m))
251pinvC m = linearSolveLSC m (ident (rows m)) 252pinvC m = linearSolveLSC m (identC (rows m))
252 253
253pinvSVDR m = linearSolveSVDR Nothing m (ident (rows m)) 254pinvSVDR m = linearSolveSVDR Nothing m (ident (rows m))
254 255
255pinvSVDC m = linearSolveSVDC Nothing m (ident (rows m)) 256pinvSVDC m = linearSolveSVDC Nothing m (identC (rows m))
256 257
257-------------------------------------------------------------------- 258--------------------------------------------------------------------
258 259