From eb28c0981f4da42c15ac267f7f6ba28d6f8bffbc Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Mon, 11 Jun 2007 12:34:06 +0000 Subject: ok linearSolve --- examples/tests.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/tests.hs b/examples/tests.hs index 53436c8..50f0a03 100644 --- a/examples/tests.hs +++ b/examples/tests.hs @@ -138,6 +138,18 @@ instance {-(Field a, Arbitrary a, Num a) =>-} Arbitrary Her where return $ Her (m `addM` (liftMatrix conj) (trans m)) coarbitrary = undefined +data PairSM a = PairSM (Matrix a) (Matrix a) deriving Show +instance (Num a, Field a, Arbitrary a) => Arbitrary (PairSM a) where + arbitrary = do + a <- choose (1,10) + c <- choose (1,10) + l1 <- vector (a*a) + l2 <- vector (a*c) + return $ PairSM ((a> v) |~~| (v <> diag (comp s)) where (s,v) = eigH m (<>) = prod +linearSolveSQTest fun eqfun singu prod (PairSM a b) = singu a || (a <> fun a b) ==== b + where (<>) = prod + (====) = eqfun + +prec = 1E-15 + +singular fun m = s1 < prec || s2/s1 < prec + where (_,ss,v) = fun m + s = toList ss + s1 = maximum s + s2 = minimum s main = do quickCheck $ \l -> null l || (toList . fromList) l == (l :: [BaseType]) @@ -204,7 +227,8 @@ main = do quickCheck (eigTestS mulF) quickCheck (eigTestH mulC) quickCheck (eigTestH mulF) - + quickCheck (linearSolveSQTest linearSolveR (|~|) (singular svdR') mulC) + quickCheck (linearSolveSQTest linearSolveC (|~~|) (singular svdC') mulC) kk = (2><2) [ 1.0, 0.0 -- cgit v1.2.3