diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-09-07 12:04:03 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-09-07 12:04:03 +0200 |
commit | 505879855c6fa83b81ab31b57daaf8034634a19e (patch) | |
tree | 9c6c1ea08d9852adf57486ffe6673dd5166ffb6d /packages/tests/src/Numeric/LinearAlgebra/Tests.hs | |
parent | e90e605787402e7e1a8d33de1a889822fc25fdc9 (diff) |
fix min/maxIndex bug, add tests, thanks
Diffstat (limited to 'packages/tests/src/Numeric/LinearAlgebra/Tests.hs')
-rw-r--r-- | packages/tests/src/Numeric/LinearAlgebra/Tests.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs index 841b0d8..8587561 100644 --- a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs +++ b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs | |||
@@ -398,12 +398,33 @@ staticTest = utest "static" (fst $ checkT (undefined :: L 3 5)) | |||
398 | 398 | ||
399 | -------------------------------------------------------------------------------- | 399 | -------------------------------------------------------------------------------- |
400 | 400 | ||
401 | indexProp g f x = a1 == g a2 && a2 == a3 && b1 == g b2 && b2 == b3 | ||
402 | where | ||
403 | l = map g (toList (f x)) | ||
404 | a1 = maximum l | ||
405 | b1 = minimum l | ||
406 | a2 = x `atIndex` maxIndex x | ||
407 | b2 = x `atIndex` minIndex x | ||
408 | a3 = maxElement x | ||
409 | b3 = minElement x | ||
410 | |||
411 | -------------------------------------------------------------------------------- | ||
412 | |||
401 | -- | All tests must pass with a maximum dimension of about 20 | 413 | -- | All tests must pass with a maximum dimension of about 20 |
402 | -- (some tests may fail with bigger sizes due to precision loss). | 414 | -- (some tests may fail with bigger sizes due to precision loss). |
403 | runTests :: Int -- ^ maximum dimension | 415 | runTests :: Int -- ^ maximum dimension |
404 | -> IO () | 416 | -> IO () |
405 | runTests n = do | 417 | runTests n = do |
406 | let test p = qCheck n p | 418 | let test p = qCheck n p |
419 | putStrLn "------ index" | ||
420 | test( \m -> indexProp id flatten (single (m :: RM)) ) | ||
421 | test( \v -> indexProp id id (single (v :: Vector Double)) ) | ||
422 | test( \m -> indexProp id flatten (m :: RM) ) | ||
423 | test( \v -> indexProp id id (v :: Vector Double) ) | ||
424 | test( \m -> indexProp magnitude flatten (single (m :: CM)) ) | ||
425 | test( \v -> indexProp magnitude id (single (v :: Vector (Complex Double))) ) | ||
426 | test( \m -> indexProp magnitude flatten (m :: CM) ) | ||
427 | test( \v -> indexProp magnitude id (v :: Vector (Complex Double)) ) | ||
407 | putStrLn "------ mult Double" | 428 | putStrLn "------ mult Double" |
408 | test (multProp1 10 . rConsist) | 429 | test (multProp1 10 . rConsist) |
409 | test (multProp1 10 . cConsist) | 430 | test (multProp1 10 . cConsist) |