Mercurial > hg > may
changeset 299:afce0ab788d1
Replace add c1 c2 with sum [c1, c2]
author | Chris Cannam |
---|---|
date | Fri, 31 May 2013 22:03:23 +0100 |
parents | 920f736f8702 |
children | ddd0938d1df8 |
files | yetilab/complex.yeti |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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> -> cplx, + multiply is cplx -> cplx -> cplx, scale is number -> cplx -> cplx, zeros is number -> array<cplx>, magnitudes is list?<cplx> -> vector,