changeset 142:9ade635dbad6

Add complex.zeros
author Chris Cannam
date Sat, 27 Apr 2013 12:51:04 +0100
parents 9852a273e559
children 476a03ca013b
files yetilab/block/complex.yeti yetilab/block/test/test_complex.yeti
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/yetilab/block/complex.yeti	Thu Apr 25 16:23:33 2013 +0100
+++ b/yetilab/block/complex.yeti	Sat Apr 27 12:51:04 2013 +0100
@@ -60,6 +60,9 @@
 scale r c is number -> ~Cplx -> ~Cplx =
     complex (r * real c) (r * imaginary c);
 
+zeros n is number -> array<~Cplx> =
+    array (map \(complex 0 0) [1..n]);
+
 {
    real,
    imaginary,
@@ -68,6 +71,7 @@
    angle,
    add,
    scale,
+   zeros,
 } as {
    real is cplx -> number,
    imaginary is cplx -> number,
@@ -76,5 +80,6 @@
    angle is cplx -> number,
    add is cplx -> cplx -> cplx,
    scale is number -> cplx -> cplx,
+   zeros is number -> array<cplx>,
 }
 
--- a/yetilab/block/test/test_complex.yeti	Thu Apr 25 16:23:33 2013 +0100
+++ b/yetilab/block/test/test_complex.yeti	Sat Apr 27 12:51:04 2013 +0100
@@ -1,6 +1,6 @@
 module yetilab.block.test.test_complex;
 
-{ real, imaginary, complex, magnitude, angle, add, scale }
+{ real, imaginary, complex, magnitude, angle, add, scale, zeros }
    = load yetilab.block.complex;
 
 { compare } = load yetilab.test.test;
@@ -40,6 +40,11 @@
     compare (scale 4 (complex 2 3)) (complex 8 12)
 ),
 
+"zeros": \(
+    compare (zeros 0) (array []) and
+        compare (zeros 3) (array [complex 0 0, complex 0 0, complex 0 0])
+),
+
 ] is hash<string, () -> boolean>;