# HG changeset patch # User Chris Cannam # Date 1406485281 -3600 # Node ID 14e3e3d5f9069fe4ce52d1c93a7eda520c093525 # Parent 1f5dd6fc196fc4d4d55ae750eb93faeb2b939b78 A couple of new complex functions diff -r 1f5dd6fc196f -r 14e3e3d5f906 src/may/complex.yeti --- a/src/may/complex.yeti Tue Jun 24 15:32:06 2014 +0100 +++ b/src/may/complex.yeti Sun Jul 27 19:21:21 2014 +0100 @@ -72,12 +72,18 @@ angle c is ~Cplx -> number = c#getAngle(); +fromPolar mag angle is number -> number -> ~Cplx = + complex (mag * Math#cos(angle)) (mag * Math#sin(angle)); + sum' cc is list?<~Cplx> -> ~Cplx = complex (sum (map real cc)) (sum (map imaginary cc)); add c1 c2 is ~Cplx -> ~Cplx -> ~Cplx = complex (real c1 + real c2) (imaginary c1 + imaginary c2); +subtract c1 c2 is ~Cplx -> ~Cplx -> ~Cplx = + complex (real c1 - real c2) (imaginary c1 - imaginary c2); + multiply c1 c2 is ~Cplx -> ~Cplx -> ~Cplx = (a = real c1; b = imaginary c1; @@ -118,8 +124,10 @@ complex, magnitude, angle, + fromPolar, sum = sum', add, + subtract, multiply, scale, zero, @@ -136,8 +144,10 @@ complex is number -> number -> complex_t, magnitude is complex_t -> number, angle is complex_t -> number, + fromPolar is number -> number -> complex_t, sum is list? -> complex_t, add is complex_t -> complex_t -> complex_t, + subtract is complex_t -> complex_t -> complex_t, multiply is complex_t -> complex_t -> complex_t, scale is number -> complex_t -> complex_t, zero is complex_t,