diff yetilab/matrix/test/test_matrix.yeti @ 229:ac1373067054

Add vector max/min, matrix difference/abs, update audiofile ref tests
author Chris Cannam
date Sun, 12 May 2013 18:04:48 +0100
parents 77c6a81c577f
children 0c86d9284f20
line wrap: on
line diff
--- a/yetilab/matrix/test/test_matrix.yeti	Sun May 12 14:56:40 2013 +0100
+++ b/yetilab/matrix/test/test_matrix.yeti	Sun May 12 18:04:48 2013 +0100
@@ -102,6 +102,19 @@
         not mat.equal m r
 ),
 
+"equalUnder-\(name)": \(
+    p = newMatrix (ColumnMajor ()) [[1,2,3],[4,5,6]];
+    q = newMatrix (ColumnMajor ()) [[1,2,3],[4,5,6]];
+    r = newMatrix (ColumnMajor ()) [[4,3,1],[3,1,2]];
+    s = newMatrix (ColumnMajor ()) [[1,2,5],[6,7,8]];
+    t = newMatrix (ColumnMajor ()) [[1,2,5],[6,7,9]];
+    mat.equalUnder (==) p p and
+        mat.equalUnder (==) p q and
+        mat.equalUnder (!=) p r and
+        mat.equalUnder do a b: a % 2 == b % 2 done p s and
+        not mat.equalUnder do a b: a % 2 == b % 2 done p t
+),
+
 "getAt-\(name)": \(
     generator row col = row * 10 + col;
     m = generate generator { rows = 2, columns = 3 };
@@ -225,6 +238,29 @@
     yrt
 ),
 
+"difference-\(name)": \(
+    compareMatrices
+       (mat.difference (constMatrix 2 { rows = 3, columns = 4 })
+                       (constMatrix 1 { rows = 3, columns = 4 }))
+       (constMatrix 1 { rows = 3, columns = 4 })
+),
+
+"differenceFail-\(name)": \(
+    try 
+      \() (mat.difference (constMatrix 2 { rows = 3, columns = 4 })
+                          (constMatrix 1 { rows = 3, columns = 5 }));
+        false;
+    catch FailureException e:
+        true
+    yrt
+),
+
+"abs-\(name)": \(
+    compareMatrices
+       (mat.abs (newMatrix (ColumnMajor ()) [[-1,4],[2,-5],[-3,0]]))
+       (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,0]])
+),
+
 "product-\(name)": \(
     compareMatrices
        (mat.product (constMatrix 2 { rows = 4, columns = 2 })