summaryrefslogtreecommitdiff
path: root/py/modcmath.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-17 14:10:13 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-17 14:10:13 +0000
commita24eafacc9653232087bde15fb86bf86cb44cb06 (patch)
tree02db9c888ad741064d48a80740d309eb0211ccc4 /py/modcmath.c
parent2c838942574a4970c922d1550f04e4b7b4d865a6 (diff)
py/modmath: Make log2, log10 and hyperbolic funcs be SPECIAL_FUNCTIONS.
Will be included only when MICROPY_PY_MATH_SPECIAL_FUNCTIONS is enabled. Also covers cmath module (but only log10 is there at the moment).
Diffstat (limited to 'py/modcmath.c')
-rw-r--r--py/modcmath.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/modcmath.c b/py/modcmath.c
index 089210d06..83d86772d 100644
--- a/py/modcmath.c
+++ b/py/modcmath.c
@@ -86,6 +86,7 @@ STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
+#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
/// \function log10(z)
/// Return the base-10 logarithm of `z`. The branch cut is along the negative real axis.
STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
@@ -94,6 +95,7 @@ STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log10)(real*real + imag*imag), 0.4342944819032518 * MICROPY_FLOAT_C_FUN(atan2)(imag, real));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
+#endif
/// \function sqrt(z)
/// Return the square-root of `z`.
@@ -133,7 +135,9 @@ STATIC const mp_map_elem_t mp_module_cmath_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_rect), (mp_obj_t)&mp_cmath_rect_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_exp), (mp_obj_t)&mp_cmath_exp_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_log), (mp_obj_t)&mp_cmath_log_obj },
+ #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
{ MP_OBJ_NEW_QSTR(MP_QSTR_log10), (mp_obj_t)&mp_cmath_log10_obj },
+ #endif
{ MP_OBJ_NEW_QSTR(MP_QSTR_sqrt), (mp_obj_t)&mp_cmath_sqrt_obj },
//{ MP_OBJ_NEW_QSTR(MP_QSTR_acos), (mp_obj_t)&mp_cmath_acos_obj },
//{ MP_OBJ_NEW_QSTR(MP_QSTR_asin), (mp_obj_t)&mp_cmath_asin_obj },