diff --git a/src/libasr/runtime/lfortran_intrinsics.c b/src/libasr/runtime/lfortran_intrinsics.c index f236ce3bae..114716d06d 100644 --- a/src/libasr/runtime/lfortran_intrinsics.c +++ b/src/libasr/runtime/lfortran_intrinsics.c @@ -665,16 +665,6 @@ LFORTRAN_API double _lfortran_zphase(double_complex_t x) return atan2(cimag(x), creal(x)); } -// rect -------------------------------------------------------------------- - -LFORTRAN_API double_complex_t _lfortran_rect(double r, double phi) -{ - double re = r*cos(phi); - double im = r*sin(phi); - double complex c = CMPLX(re, im); - return c; -} - // strcat -------------------------------------------------------------------- LFORTRAN_API void _lfortran_strcat(char** s1, char** s2, char** dest) diff --git a/src/libasr/runtime/lfortran_intrinsics.h b/src/libasr/runtime/lfortran_intrinsics.h index 771f069999..ae01305df2 100644 --- a/src/libasr/runtime/lfortran_intrinsics.h +++ b/src/libasr/runtime/lfortran_intrinsics.h @@ -139,7 +139,6 @@ LFORTRAN_API float_complex_t _lfortran_catanh(float_complex_t x); LFORTRAN_API double_complex_t _lfortran_zatanh(double_complex_t x); LFORTRAN_API float _lfortran_cphase(float_complex_t x); LFORTRAN_API double _lfortran_zphase(double_complex_t x); -LFORTRAN_API double_complex_t _lfortran_rect(double r, double phi); LFORTRAN_API bool _lpython_str_compare_eq(char** s1, char** s2); LFORTRAN_API bool _lpython_str_compare_noteq(char** s1, char** s2); LFORTRAN_API bool _lpython_str_compare_gt(char** s1, char** s2); diff --git a/src/runtime/cmath.py b/src/runtime/cmath.py index 87c6a1b346..271f962542 100644 --- a/src/runtime/cmath.py +++ b/src/runtime/cmath.py @@ -1,5 +1,4 @@ from lpython import c64, ccall, f64, overload, c32, f32 -from lpython_builtin import abs pi: f64 = 3.141592653589793238462643383279502884197 e: f64 = 2.718281828459045235360287471352662497757 @@ -278,10 +277,13 @@ def polar(x: c32) -> tuple[f32, f32]: def polar(x: c64) -> tuple[f64, f64]: return (abs(x), phase(x)) +@ccall +def _lfortran_dcos(x: f64) -> f64: + pass @ccall -def _lfortran_rect(r: f64, phi: f64) -> c64: +def _lfortran_dsin(x: f64) -> f64: pass def rect(r: f64, phi: f64) -> c64: - return _lfortran_rect(r, phi) + return c64(complex(r*_lfortran_dcos(phi), r*_lfortran_dsin(phi)))