From: fennecdjay Date: Sat, 8 Jun 2019 15:31:07 +0000 (+0200) Subject: :art: Fix polar on Windows/clang ? (again) X-Git-Tag: nightly~2443^2~5 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=f858824a1b49241a7528945ce09966dc413731a2;p=gwion.git :art: Fix polar on Windows/clang ? (again) --- diff --git a/src/lib/complex.c b/src/lib/complex.c index c727d42a..6ed55aed 100644 --- a/src/lib/complex.c +++ b/src/lib/complex.c @@ -92,21 +92,21 @@ static INSTR(PolarR##name) {\ const m_complex b = **(m_complex**)REG(0); \ const m_float re = creal(a) * cos(cimag(a)) op creal(b) * cos(cimag(b)); \ const m_float im = creal(a) * sin(cimag(a)) op creal(b) * sin(cimag(b)); \ - *(m_complex*)REG(-SZ_COMPLEX) = **(m_complex**)REG(0) = \ - hypot(re, im) + atan2(im, re) * I; \ + POLAR(c, hypot(re, im), atan2(im, re)) \ + *(m_complex*)REG(-SZ_COMPLEX) = **(m_complex**)REG(0) = c; \ } polar_def1_r(Add, +) polar_def1_r(Sub, -) -#define polar_def2_r(name, op1, op2) \ -static INSTR(PolarR##name) {\ - POP_REG(shred, SZ_INT); \ - const m_complex a = *(m_complex*)REG(-SZ_COMPLEX); \ - const m_complex b = **(m_complex**)REG(0); \ - const m_float mag = creal(a) op1 creal(b); \ - const m_float phase = cimag(a) op2 cimag(b); \ - *(m_complex*)REG(-SZ_COMPLEX) = **(m_complex**)REG(0) = \ - mag + phase * I; \ +#define polar_def2_r(name, op1, op2) \ +static INSTR(PolarR##name) { \ + POP_REG(shred, SZ_INT); \ + const m_complex a = *(m_complex*)REG(-SZ_COMPLEX); \ + const m_complex b = **(m_complex**)REG(0); \ + const m_float mag = creal(a) op1 creal(b); \ + const m_float phase = cimag(a) op2 cimag(b); \ + POLAR(c, mag, phase); \ + *(m_complex*)REG(-SZ_COMPLEX) = **(m_complex**)REG(0) = c; \ } polar_def2_r(Mul, *, +) polar_def2_r(Div, /, -)