From 42bec1ac9911131b552f66779203eb599a86563d Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Tue, 2 Oct 2007 18:59:50 +0000 Subject: lapack real and complex unpacked QR --- examples/tests.hs | 14 +++++++++++++- examples/usaStatic.hs | 36 ------------------------------------ examples/useStatic.hs | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 37 deletions(-) delete mode 100644 examples/usaStatic.hs create mode 100644 examples/useStatic.hs (limited to 'examples') diff --git a/examples/tests.hs b/examples/tests.hs index b088069..b3272cf 100644 --- a/examples/tests.hs +++ b/examples/tests.hs @@ -7,7 +7,8 @@ import Numeric.GSL hiding (sin,cos,exp,choose) import Numeric.LinearAlgebra import Numeric.LinearAlgebra.Linear(Linear) import Numeric.LinearAlgebra.LAPACK -import Numeric.GSL.Matrix +import Numeric.GSL.Matrix(svdg) +import qualified Numeric.GSL.Matrix as GSL import Test.QuickCheck hiding (test) import Test.HUnit hiding ((~:),test) import System.Random(randomRs,mkStdGen) @@ -271,6 +272,11 @@ cholCTest = chol ((2><2) [1,2,2,9::Complex Double]) == (2><2) [1,2,0,2.236067977 --------------------------------------------------------------------- +qrTest qr m = q <> r |~| m -- && q <> ctrans q |~| ident (rows m) + where (q,r) = qr m + +--------------------------------------------------------------------- + asFortran m = (rows m >|< cols m) $ toList (fdat m) asC m = (rows m >< cols m) $ toList (cdat m) @@ -322,6 +328,12 @@ tests = do [ test "cholR" cholRTest , test "cholC" cholRTest ] + putStrLn "--------- qr ---------" + quickCheck (qrTest GSL.qr) + quickCheck (qrTest (GSL.unpackQR . GSL.qrPacked)) + quickCheck (qrTest ( unpackQR . GSL.qrPacked)) + quickCheck (qrTest qr ::RM->Bool) + quickCheck (qrTest qr ::CM->Bool) putStrLn "--------- nullspace ------" quickCheck (nullspaceTest :: RM -> Bool) quickCheck (nullspaceTest :: CM -> Bool) diff --git a/examples/usaStatic.hs b/examples/usaStatic.hs deleted file mode 100644 index 619af8f..0000000 --- a/examples/usaStatic.hs +++ /dev/null @@ -1,36 +0,0 @@ -{-# OPTIONS -fno-monomorphism-restriction #-} - -import Static -import Numeric.LinearAlgebra - - -x = $(vec [1,2]) - -y = $(vec [5,7]) - -z a = vec [a,a] - -w = $(vec [1,2,3]) - -cx = $(covec [1,2,3]) - - -t3 = $(tdim 3) - -crm33 = createml t3 t3 3 3 - -rot a = crm33 [a,0,0,0,a,0,0,0,1] - ---q = x |+| y |+| $(z 5) - -m = $(mat 2 3 [1..6]) - -n = $(mat 3 5 [1..15]) - -infixl 7 <*> -(<*>) = prod - -r1 = m <*> n -r2 = strans (strans n <*> strans m) - ---r' = prod n m diff --git a/examples/useStatic.hs b/examples/useStatic.hs new file mode 100644 index 0000000..619af8f --- /dev/null +++ b/examples/useStatic.hs @@ -0,0 +1,36 @@ +{-# OPTIONS -fno-monomorphism-restriction #-} + +import Static +import Numeric.LinearAlgebra + + +x = $(vec [1,2]) + +y = $(vec [5,7]) + +z a = vec [a,a] + +w = $(vec [1,2,3]) + +cx = $(covec [1,2,3]) + + +t3 = $(tdim 3) + +crm33 = createml t3 t3 3 3 + +rot a = crm33 [a,0,0,0,a,0,0,0,1] + +--q = x |+| y |+| $(z 5) + +m = $(mat 2 3 [1..6]) + +n = $(mat 3 5 [1..15]) + +infixl 7 <*> +(<*>) = prod + +r1 = m <*> n +r2 = strans (strans n <*> strans m) + +--r' = prod n m -- cgit v1.2.3