aboutsummaryrefslogtreecommitdiff
path: root/py/modmath.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-17 17:11:03 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-17 17:11:03 +0100
commitdbdfee15a1839858b4d12f352b2e34597e6e76e9 (patch)
treedb3d1cae2a4b3c3bdc825a226b818d728100fe8d /py/modmath.c
parentfb06bfc11ccc2506d27e3f53750771d5c737df2e (diff)
py: Add cmath module, for complex math. Disabled by default.
Not all functions implemented. Not enabled on pyboard.
Diffstat (limited to 'py/modmath.c')
-rw-r--r--py/modmath.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/py/modmath.c b/py/modmath.c
index c26ba1618..09bb4ce3a 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -6,7 +6,7 @@
#include "obj.h"
#include "builtin.h"
-#if MICROPY_ENABLE_FLOAT
+#if MICROPY_ENABLE_FLOAT && MICROPY_ENABLE_MOD_MATH
//TODO: Change macros to check for overflow and raise OverflowError or RangeError
#define MATH_FUN_1(py_name, c_name) \
@@ -25,8 +25,9 @@
mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_int((machine_int_t)MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
-STATIC const mp_obj_float_t mp_math_e_obj = {{&mp_type_float}, M_E};
-STATIC const mp_obj_float_t mp_math_pi_obj = {{&mp_type_float}, M_PI};
+// These are also used by cmath.c
+const mp_obj_float_t mp_math_e_obj = {{&mp_type_float}, M_E};
+const mp_obj_float_t mp_math_pi_obj = {{&mp_type_float}, M_PI};
MATH_FUN_1(sqrt, sqrt)
MATH_FUN_2(pow, pow)
@@ -156,4 +157,4 @@ const mp_obj_module_t mp_module_math = {
.globals = (mp_obj_dict_t*)&mp_module_math_globals,
};
-#endif // MICROPY_ENABLE_FLOAT
+#endif // MICROPY_ENABLE_FLOAT && MICROPY_ENABLE_MOD_MATH