diff yetilab/vector/test/test_blockfuncs.yeti @ 222:77c6a81c577f matrix_opaque_immutable

Move block directory -> vector
author Chris Cannam
date Sat, 11 May 2013 15:58:36 +0100
parents yetilab/block/test/test_blockfuncs.yeti@26111c11d8e4
children ac1373067054
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yetilab/vector/test/test_blockfuncs.yeti	Sat May 11 15:58:36 2013 +0100
@@ -0,0 +1,68 @@
+
+module yetilab.vector.test.test_blockfuncs;
+
+stdSqrt = sqrt;
+
+{ zeros, consts, ones, fromList, list } = load yetilab.vector.vector;
+{ sum, mean, multiply, divideBy, sqr, sqrt, rms, fftshift, ifftshift } = load yetilab.vector.blockfuncs;
+{ compare } = load yetilab.test.test;
+
+[
+
+"sum": \(
+    compare ((sum . zeros) 0) 0 and
+        compare ((sum . zeros) 5) 0 and
+        compare ((sum . ones) 5) 5 and
+        compare ((sum . fromList) [1,-2,3,0]) 2
+),
+
+"mean": \(
+    compare ((mean . zeros) 0) 0 and
+        compare ((mean . zeros) 5) 0 and
+        compare ((mean . ones) 5) 1 and
+        compare ((mean . fromList) [1,-2,3,0]) 0.5
+),
+
+"multiply": \(
+    compare (list (multiply (zeros 0) (ones 5))) [] and
+        compare (list (multiply (consts (-3) 4) (fromList [1,2,3]))) [-3,-6,-9]
+),
+
+"divideBy": \(
+    compare (list (divideBy 5 (ones 0))) [] and
+        compare (list (divideBy 5 (fromList [1,2,-3]))) [0.2,0.4,-0.6]
+),
+
+"sqr": \(
+    compare ((list . sqr . zeros) 0) [] and
+        compare ((list . sqr . ones) 5) [1,1,1,1,1] and
+        compare ((list . sqr . fromList) [0.5,-2,3,0]) [0.25,4,9,0]
+),
+
+"sqrt": \(
+    compare ((list . sqrt . zeros) 0) [] and
+        compare ((list . sqrt . ones) 5) [1,1,1,1,1] and
+        compare ((list . sqrt . fromList) [0.25,4,9,0]) [0.5,2,3,0]
+),
+
+"rms": \(
+    compare ((rms . zeros) 0) 0 and
+        compare ((rms . ones) 5) 1 and
+        compare ((rms . fromList) [-1,2,2]) (stdSqrt 3)
+),
+
+"fftshift": \(
+    compare ((list . fftshift . zeros) 0) [] and 
+        compare ((list . fftshift . fromList) [1,2,3,4]) [3,4,1,2] and
+        compare ((list . fftshift . fromList) [1,2,3,4,5]) [4,5,1,2,3]
+),
+
+"ifftshift": \(
+    compare ((list . ifftshift . zeros) 0) [] and 
+        compare ((list . ifftshift . fromList) [3,4,1,2]) [1,2,3,4] and
+        compare ((list . ifftshift . fromList) [4,5,1,2,3]) [1,2,3,4,5]
+),
+
+] is hash<string, () -> boolean>;
+
+