Commit 5cbeaceb by Damien George

### py: Make math special functions configurable and disabled by default.

```The implementation of these functions is very large (order 4k) and they
are rarely used, so we don't enable them by default.

They are however enabled in stmhal and unix, since we have the room.```
parent 9ab94c46
 ... @@ -120,6 +120,7 @@ MATH_FUN_1_TO_BOOL(isnan, isnan) ... @@ -120,6 +120,7 @@ MATH_FUN_1_TO_BOOL(isnan, isnan) MATH_FUN_1_TO_INT(trunc, trunc) MATH_FUN_1_TO_INT(trunc, trunc) /// \function ldexp(x, exp) /// \function ldexp(x, exp) MATH_FUN_2(ldexp, ldexp) MATH_FUN_2(ldexp, ldexp) #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS /// \function erf(x) /// \function erf(x) /// Return the error function of `x`. /// Return the error function of `x`. MATH_FUN_1(erf, erf) MATH_FUN_1(erf, erf) ... @@ -132,6 +133,7 @@ MATH_FUN_1(gamma, tgamma) ... @@ -132,6 +133,7 @@ MATH_FUN_1(gamma, tgamma) /// \function lgamma(x) /// \function lgamma(x) /// return the natural logarithm of the gamma function of `x`. /// return the natural logarithm of the gamma function of `x`. MATH_FUN_1(lgamma, lgamma) MATH_FUN_1(lgamma, lgamma) #endif //TODO: factorial, fsum //TODO: factorial, fsum // Functions that return a tuple // Functions that return a tuple ... @@ -211,10 +213,12 @@ STATIC const mp_map_elem_t mp_module_math_globals_table[] = { ... @@ -211,10 +213,12 @@ STATIC const mp_map_elem_t mp_module_math_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_trunc), (mp_obj_t)&mp_math_trunc_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_trunc), (mp_obj_t)&mp_math_trunc_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_radians), (mp_obj_t)&mp_math_radians_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_radians), (mp_obj_t)&mp_math_radians_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_degrees), (mp_obj_t)&mp_math_degrees_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_degrees), (mp_obj_t)&mp_math_degrees_obj }, #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS { MP_OBJ_NEW_QSTR(MP_QSTR_erf), (mp_obj_t)&mp_math_erf_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_erf), (mp_obj_t)&mp_math_erf_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_erfc), (mp_obj_t)&mp_math_erfc_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_erfc), (mp_obj_t)&mp_math_erfc_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_gamma), (mp_obj_t)&mp_math_gamma_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_gamma), (mp_obj_t)&mp_math_gamma_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_lgamma), (mp_obj_t)&mp_math_lgamma_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_lgamma), (mp_obj_t)&mp_math_lgamma_obj }, #endif }; }; STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table); STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table); ... ...
 ... @@ -419,6 +419,11 @@ typedef double mp_float_t; ... @@ -419,6 +419,11 @@ typedef double mp_float_t; #define MICROPY_PY_MATH (1) #define MICROPY_PY_MATH (1) #endif #endif // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma} #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) #endif // Whether to provide "cmath" module // Whether to provide "cmath" module #ifndef MICROPY_PY_CMATH #ifndef MICROPY_PY_CMATH #define MICROPY_PY_CMATH (0) #define MICROPY_PY_CMATH (0) ... ...
 ... @@ -363,11 +363,13 @@ Q(frexp) ... @@ -363,11 +363,13 @@ Q(frexp) Q(ldexp) Q(ldexp) Q(degrees) Q(degrees) Q(radians) Q(radians) #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS Q(erf) Q(erf) Q(erfc) Q(erfc) Q(gamma) Q(gamma) Q(lgamma) Q(lgamma) #endif #endif #endif #if MICROPY_PY_CMATH #if MICROPY_PY_CMATH Q(cmath) Q(cmath) ... ...
 ... @@ -61,6 +61,7 @@ ... @@ -61,6 +61,7 @@ #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_SYS_EXIT (1) #define MICROPY_PY_SYS_EXIT (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1) #define MICROPY_PY_CMATH (1) #define MICROPY_PY_CMATH (1) #define MICROPY_PY_IO (1) #define MICROPY_PY_IO (1) #define MICROPY_PY_IO_FILEIO (1) #define MICROPY_PY_IO_FILEIO (1) ... ...
 ... @@ -64,6 +64,7 @@ ... @@ -64,6 +64,7 @@ #define MICROPY_PY_SYS_PLATFORM "linux" #define MICROPY_PY_SYS_PLATFORM "linux" #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1) #define MICROPY_PY_CMATH (1) #define MICROPY_PY_CMATH (1) #define MICROPY_PY_IO_FILEIO (1) #define MICROPY_PY_IO_FILEIO (1) #define MICROPY_PY_GC_COLLECT_RETVAL (1) #define MICROPY_PY_GC_COLLECT_RETVAL (1) ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!