Mercurial > hg > may
changeset 586:14e3e3d5f906
A couple of new complex functions
author | Chris Cannam |
---|---|
date | Sun, 27 Jul 2014 19:21:21 +0100 |
parents | 1f5dd6fc196f |
children | b50912d6d72b |
files | src/may/complex.yeti |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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> -> 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,