# HG changeset patch # User Chris Cannam # Date 1370034203 -3600 # Node ID afce0ab788d19bf1c113c4ffac7d022640bdcea4 # Parent 920f736f87024d0f7c15b996c87b926b16ee4285 Replace add c1 c2 with sum [c1, c2] diff -r 920f736f8702 -r afce0ab788d1 yetilab/complex.yeti --- a/yetilab/complex.yeti Fri May 31 22:02:54 2013 +0100 +++ b/yetilab/complex.yeti Fri May 31 22:03:23 2013 +0100 @@ -57,8 +57,15 @@ angle c is ~Cplx -> number = c#getAngle(); -add c1 c2 is ~Cplx -> ~Cplx -> ~Cplx = - complex (real c1 + real c2) (imaginary c1 + imaginary c2); +sum' cc is list?<~Cplx> -> ~Cplx = + complex (sum (map real cc)) (sum (map imaginary cc)); + +multiply c1 c2 is ~Cplx -> ~Cplx -> ~Cplx = + (a = real c1; + b = imaginary c1; + c = real c2; + d = imaginary c2; + complex (a * c - b * d) (b * c + a * d)); //!!! need units scale r c is number -> ~Cplx -> ~Cplx = complex (r * real c) (r * imaginary c); @@ -78,7 +85,8 @@ complex, magnitude, angle, - add, + sum = sum', + multiply, scale, zeros, magnitudes, @@ -89,7 +97,8 @@ complex is number -> number -> cplx, magnitude is cplx -> number, angle is cplx -> number, - add is cplx -> cplx -> cplx, + sum is list? -> cplx, + multiply is cplx -> cplx -> cplx, scale is number -> cplx -> cplx, zeros is number -> array, magnitudes is list? -> vector,