diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-05-28 11:53:11 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-05-28 12:26:14 +0200 |
commit | a4250d0887462b123aa4d2a3d21dddc323ee4ee1 (patch) | |
tree | 232179a952e895136e152b909cdc6dd9173d9e93 /packages/base/src/Numeric/LinearAlgebra | |
parent | c0409bdce707fed49bedb213c21e6cc3e23b9aec (diff) |
general Range, test
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Util.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs index f09bdb5..8d9f842 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Util.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs | |||
@@ -312,6 +312,8 @@ size = size' | |||
312 | >>> vector [1..10] ! 3 | 312 | >>> vector [1..10] ! 3 |
313 | 4.0 | 313 | 4.0 |
314 | 314 | ||
315 | On a matrix it gets the k-th row as a vector: | ||
316 | |||
315 | >>> matrix 5 [1..15] ! 1 | 317 | >>> matrix 5 [1..15] ! 1 |
316 | fromList [6.0,7.0,8.0,9.0,10.0] | 318 | fromList [6.0,7.0,8.0,9.0,10.0] |
317 | 319 | ||
@@ -479,12 +481,18 @@ instance Testable (Matrix I) where | |||
479 | checkT _ = test | 481 | checkT _ = test |
480 | 482 | ||
481 | test :: (Bool, IO()) | 483 | test :: (Bool, IO()) |
482 | test = (and ok, print ok) | 484 | test = (and ok, return ()) |
483 | where | 485 | where |
484 | m = (3><4) [1..12] :: Matrix I | 486 | m = (3><4) [1..12] :: Matrix I |
487 | r = (2><3) [1,2,3,4,3,2] | ||
488 | c = (3><2) [0,4,4,1,2,3] | ||
489 | p = (9><10) [0..89] :: Matrix I | ||
490 | ep = (2><3) [10,24,32,44,31,23] | ||
485 | md = fromInt m :: Matrix Double | 491 | md = fromInt m :: Matrix Double |
486 | ok = [ tr m <> m == toInt (tr md <> md) | 492 | ok = [ tr m <> m == toInt (tr md <> md) |
487 | , m <> tr m == toInt (md <> tr md) | 493 | , m <> tr m == toInt (md <> tr md) |
488 | , m ?? (Take 2, Take 3) == remap (asColumn (range 2)) (asRow (range 3)) m | 494 | , m ?? (Take 2, Take 3) == remap (asColumn (range 2)) (asRow (range 3)) m |
495 | , remap r (tr c) p == ep | ||
496 | , tr p ?? (PosCyc (idxs[-5,13]), Pos (idxs[3,7,1])) == (2><3) [35,75,15,33,73,13] | ||
489 | ] | 497 | ] |
490 | 498 | ||