diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-04-10 10:00:43 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-04-10 10:00:43 +0200 |
commit | 3aa140213de434ab6ee6736142fd54c967f34ee9 (patch) | |
tree | ec0c23703a1a19d2f81c19abd74bb8bc7bc16683 /packages | |
parent | fde36f1224d4b87a32019bd9519d0aba4315792b (diff) |
fix tests
Diffstat (limited to 'packages')
-rw-r--r-- | packages/tests/src/Numeric/GSL/Tests.hs | 2 | ||||
-rw-r--r-- | packages/tests/src/Numeric/LinearAlgebra/Tests.hs | 14 | ||||
-rw-r--r-- | packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs | 4 |
3 files changed, 11 insertions, 9 deletions
diff --git a/packages/tests/src/Numeric/GSL/Tests.hs b/packages/tests/src/Numeric/GSL/Tests.hs index 2e225b6..e5d205d 100644 --- a/packages/tests/src/Numeric/GSL/Tests.hs +++ b/packages/tests/src/Numeric/GSL/Tests.hs | |||
@@ -42,7 +42,7 @@ fittingTest = utest "levmar" (ok1 && ok2) | |||
42 | sol = fst $ fitModel 1E-4 1E-4 20 (expModel, expModelDer) dat [1,0,0] | 42 | sol = fst $ fitModel 1E-4 1E-4 20 (expModel, expModelDer) dat [1,0,0] |
43 | 43 | ||
44 | ok1 = and (zipWith f sols [5,0.1,1]) where f (x,d) r = abs (x-r)<2*d | 44 | ok1 = and (zipWith f sols [5,0.1,1]) where f (x,d) r = abs (x-r)<2*d |
45 | ok2 = norm2 (fromList (map fst sols) - fromList sol) < 1E-5 | 45 | ok2 = norm_2 (fromList (map fst sols) - fromList sol) < 1E-5 |
46 | 46 | ||
47 | --------------------------------------------------------------------- | 47 | --------------------------------------------------------------------- |
48 | 48 | ||
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs index 14d02e4..a25f4cb 100644 --- a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs +++ b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs | |||
@@ -1,9 +1,9 @@ | |||
1 | {-# LANGUAGE CPP #-} | 1 | {-# LANGUAGE CPP #-} |
2 | {-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-incomplete-patterns #-} | 2 | {-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-incomplete-patterns #-} |
3 | {-# LANGUAGE DataKinds #-} | 3 | {-# LANGUAGE DataKinds #-} |
4 | {-# LANGUAGE TypeFamilies #-} | ||
4 | {-# LANGUAGE FlexibleContexts #-} | 5 | {-# LANGUAGE FlexibleContexts #-} |
5 | {-# LANGUAGE GADTs #-} | 6 | {-# LANGUAGE RankNTypes #-} |
6 | |||
7 | 7 | ||
8 | ----------------------------------------------------------------------------- | 8 | ----------------------------------------------------------------------------- |
9 | {- | | 9 | {- | |
@@ -30,7 +30,7 @@ module Numeric.LinearAlgebra.Tests( | |||
30 | 30 | ||
31 | import Numeric.LinearAlgebra.HMatrix | 31 | import Numeric.LinearAlgebra.HMatrix |
32 | import Numeric.LinearAlgebra.Devel hiding (vec) | 32 | import Numeric.LinearAlgebra.Devel hiding (vec) |
33 | import Numeric.LinearAlgebra.Util hiding (ones) | 33 | import Numeric.LinearAlgebra.HMatrix.Util |
34 | import Numeric.LinearAlgebra.Static(L) | 34 | import Numeric.LinearAlgebra.Static(L) |
35 | import Numeric.LinearAlgebra.Tests.Instances | 35 | import Numeric.LinearAlgebra.Tests.Instances |
36 | import Numeric.LinearAlgebra.Tests.Properties | 36 | import Numeric.LinearAlgebra.Tests.Properties |
@@ -52,6 +52,7 @@ import Control.Monad(ap) | |||
52 | import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector | 52 | import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector |
53 | ,sized,classify,Testable,Property | 53 | ,sized,classify,Testable,Property |
54 | ,quickCheckWithResult,maxSize,stdArgs,shrink) | 54 | ,quickCheckWithResult,maxSize,stdArgs,shrink) |
55 | import qualified Test.QuickCheck as T | ||
55 | 56 | ||
56 | import Test.QuickCheck.Test(isSuccess) | 57 | import Test.QuickCheck.Test(isSuccess) |
57 | 58 | ||
@@ -413,7 +414,8 @@ indexProp g f x = a1 == g a2 && a2 == a3 && b1 == g b2 && b2 == b3 | |||
413 | runTests :: Int -- ^ maximum dimension | 414 | runTests :: Int -- ^ maximum dimension |
414 | -> IO () | 415 | -> IO () |
415 | runTests n = do | 416 | runTests n = do |
416 | let test p = qCheck n p | 417 | let test :: forall t . T.Testable t => t -> IO () |
418 | test p = qCheck n p | ||
417 | putStrLn "------ index" | 419 | putStrLn "------ index" |
418 | test( \m -> indexProp id flatten (single (m :: RM)) ) | 420 | test( \m -> indexProp id flatten (single (m :: RM)) ) |
419 | test( \v -> indexProp id id (single (v :: Vector Double)) ) | 421 | test( \v -> indexProp id id (single (v :: Vector Double)) ) |
@@ -485,7 +487,7 @@ runTests n = do | |||
485 | test (svdProp6b) | 487 | test (svdProp6b) |
486 | test (svdProp7 . rM) | 488 | test (svdProp7 . rM) |
487 | test (svdProp7 . cM) | 489 | test (svdProp7 . cM) |
488 | putStrLn "------ svdCd" | 490 | -- putStrLn "------ svdCd" |
489 | #ifdef NOZGESDD | 491 | #ifdef NOZGESDD |
490 | -- putStrLn "Omitted" | 492 | -- putStrLn "Omitted" |
491 | #else | 493 | #else |
@@ -532,7 +534,7 @@ runTests n = do | |||
532 | test (\u -> sin u ** 2 + cos u ** 2 |~| (1::RM)) | 534 | test (\u -> sin u ** 2 + cos u ** 2 |~| (1::RM)) |
533 | test (\u -> cos u * tan u |~| sin (u::RM)) | 535 | test (\u -> cos u * tan u |~| sin (u::RM)) |
534 | test $ (\u -> cos u * tan u |~| sin (u::CM)) . liftMatrix makeUnitary | 536 | test $ (\u -> cos u * tan u |~| sin (u::CM)) . liftMatrix makeUnitary |
535 | putStrLn "------ vector operations - Float" | 537 | -- putStrLn "------ vector operations - Float" |
536 | -- test (\u -> sin u ^ 2 + cos u ^ 2 |~~| (1::FM)) | 538 | -- test (\u -> sin u ^ 2 + cos u ^ 2 |~~| (1::FM)) |
537 | -- test $ (\u -> sin u ^ 2 + cos u ^ 2 |~~| (1::ZM)) . liftMatrix makeUnitary | 539 | -- test $ (\u -> sin u ^ 2 + cos u ^ 2 |~~| (1::ZM)) . liftMatrix makeUnitary |
538 | -- test (\u -> sin u ** 2 + cos u ** 2 |~~| (1::FM)) | 540 | -- test (\u -> sin u ** 2 + cos u ** 2 |~~| (1::FM)) |
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs index d9645c3..941f747 100644 --- a/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs +++ b/packages/tests/src/Numeric/LinearAlgebra/Tests/Properties.hs | |||
@@ -1,6 +1,6 @@ | |||
1 | {-# LANGUAGE CPP, FlexibleContexts #-} | 1 | {-# LANGUAGE CPP, FlexibleContexts #-} |
2 | {-# OPTIONS_GHC -fno-warn-unused-imports #-} | 2 | {-# OPTIONS_GHC -fno-warn-unused-imports #-} |
3 | {-# LANGUAGE GADTs #-} | 3 | {-# LANGUAGE TypeFamilies #-} |
4 | 4 | ||
5 | ----------------------------------------------------------------------------- | 5 | ----------------------------------------------------------------------------- |
6 | {- | | 6 | {- | |
@@ -272,5 +272,5 @@ linearSolveProp2 f (a,x) = not wc `trivial` (not wc || a <> f a b |~| b) | |||
272 | b = a <> x | 272 | b = a <> x |
273 | wc = rank a == q | 273 | wc = rank a == q |
274 | 274 | ||
275 | subProp m = m == (tr . fromColumns . toRows) m | 275 | subProp m = m == (conj . tr . fromColumns . toRows) m |
276 | 276 | ||