blob: 0c70f34cd1ece7f1303f5c39860313443228f9dd [file] [log] [blame]
Damien George04b91472014-05-03 23:27:38 +01001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2013, 2014 Damien P. George
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
Damien George51dfcb42015-01-01 20:27:54 +000027#include "py/builtin.h"
Michael Buesch17298af2015-12-10 13:28:37 +010028#include "py/nlr.h"
Damien George0c36da02014-03-08 15:24:39 +000029
Damien Georgefb510b32014-06-01 13:32:54 +010030#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH
Damien George0c36da02014-03-08 15:24:39 +000031
Damien George51dfcb42015-01-01 20:27:54 +000032#include <math.h>
33
Colin Hogbena8969512016-05-09 22:11:34 +010034// M_PI is not part of the math.h standard and may not be defined
35#ifndef M_PI
36#define M_PI (3.14159265358979323846)
37#endif
38
Damien George30dd23a2014-08-10 17:50:28 +010039/// \module math - mathematical functions
40///
41/// The `math` module provides some basic mathematical funtions for
42/// working with floating-point numbers.
43
Michael Buesch17298af2015-12-10 13:28:37 +010044STATIC NORETURN void math_error(void) {
45 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "math domain error"));
46}
47
Damien George0c36da02014-03-08 15:24:39 +000048#define MATH_FUN_1(py_name, c_name) \
Damien George969a6b32014-12-10 22:07:04 +000049 STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
Damien George0c36da02014-03-08 15:24:39 +000050 STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
51
52#define MATH_FUN_2(py_name, c_name) \
Damien George969a6b32014-12-10 22:07:04 +000053 STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj, mp_obj_t y_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_float(y_obj))); } \
Damien George0c36da02014-03-08 15:24:39 +000054 STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name);
55
Damien George084ef372014-04-01 21:21:50 +010056#define MATH_FUN_1_TO_BOOL(py_name, c_name) \
Paul Sokolovsky1b586f32015-10-11 12:09:43 +030057 STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
Rachel Dowdall249b9c72014-03-22 14:39:33 +000058 STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
59
Damien George084ef372014-04-01 21:21:50 +010060#define MATH_FUN_1_TO_INT(py_name, c_name) \
Damien George969a6b32014-12-10 22:07:04 +000061 STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { mp_int_t x = MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj)); return mp_obj_new_int(x); } \
Damien George084ef372014-04-01 21:21:50 +010062 STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
63
Michael Buesch17298af2015-12-10 13:28:37 +010064#define MATH_FUN_1_ERRCOND(py_name, c_name, error_condition) \
65 STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { \
66 mp_float_t x = mp_obj_get_float(x_obj); \
67 if (error_condition) { \
68 math_error(); \
69 } \
70 return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(x)); \
71 } \
72 STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
73
Paul Sokolovsky6d1eabf2015-11-13 13:24:39 +020074#if MP_NEED_LOG2
75// 1.442695040888963407354163704 is 1/_M_LN2
76#define log2(x) (log(x) * 1.442695040888963407354163704)
77#endif
78
Damien George30dd23a2014-08-10 17:50:28 +010079/// \function sqrt(x)
80/// Returns the square root of `x`.
Michael Buesch17298af2015-12-10 13:28:37 +010081MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0))
Damien George30dd23a2014-08-10 17:50:28 +010082/// \function pow(x, y)
83/// Returns `x` to the power of `y`.
Damien George0c36da02014-03-08 15:24:39 +000084MATH_FUN_2(pow, pow)
Damien George30dd23a2014-08-10 17:50:28 +010085/// \function exp(x)
Damien George0c36da02014-03-08 15:24:39 +000086MATH_FUN_1(exp, exp)
Paul Sokolovsky0d6116d2015-11-14 00:46:12 +020087#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
Damien George30dd23a2014-08-10 17:50:28 +010088/// \function expm1(x)
Damien George8854e1f2014-03-12 21:31:41 +000089MATH_FUN_1(expm1, expm1)
Damien George30dd23a2014-08-10 17:50:28 +010090/// \function log2(x)
Michael Buesch17298af2015-12-10 13:28:37 +010091MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0))
Damien George30dd23a2014-08-10 17:50:28 +010092/// \function log10(x)
Michael Buesch17298af2015-12-10 13:28:37 +010093MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0))
Damien George30dd23a2014-08-10 17:50:28 +010094/// \function cosh(x)
Damien George0c36da02014-03-08 15:24:39 +000095MATH_FUN_1(cosh, cosh)
Damien George30dd23a2014-08-10 17:50:28 +010096/// \function sinh(x)
Damien George0c36da02014-03-08 15:24:39 +000097MATH_FUN_1(sinh, sinh)
Damien George30dd23a2014-08-10 17:50:28 +010098/// \function tanh(x)
Damien George0c36da02014-03-08 15:24:39 +000099MATH_FUN_1(tanh, tanh)
Damien George30dd23a2014-08-10 17:50:28 +0100100/// \function acosh(x)
Damien George0c36da02014-03-08 15:24:39 +0000101MATH_FUN_1(acosh, acosh)
Damien George30dd23a2014-08-10 17:50:28 +0100102/// \function asinh(x)
Damien George0c36da02014-03-08 15:24:39 +0000103MATH_FUN_1(asinh, asinh)
Damien George30dd23a2014-08-10 17:50:28 +0100104/// \function atanh(x)
Damien George0c36da02014-03-08 15:24:39 +0000105MATH_FUN_1(atanh, atanh)
Damien Georgea24eafa2015-11-17 14:10:13 +0000106#endif
Damien George30dd23a2014-08-10 17:50:28 +0100107/// \function cos(x)
Damien George0c36da02014-03-08 15:24:39 +0000108MATH_FUN_1(cos, cos)
Damien George30dd23a2014-08-10 17:50:28 +0100109/// \function sin(x)
Damien George0c36da02014-03-08 15:24:39 +0000110MATH_FUN_1(sin, sin)
Damien George30dd23a2014-08-10 17:50:28 +0100111/// \function tan(x)
Damien George0c36da02014-03-08 15:24:39 +0000112MATH_FUN_1(tan, tan)
Damien George30dd23a2014-08-10 17:50:28 +0100113/// \function acos(x)
Damien George0c36da02014-03-08 15:24:39 +0000114MATH_FUN_1(acos, acos)
Damien George30dd23a2014-08-10 17:50:28 +0100115/// \function asin(x)
Damien George0c36da02014-03-08 15:24:39 +0000116MATH_FUN_1(asin, asin)
Damien George30dd23a2014-08-10 17:50:28 +0100117/// \function atan(x)
Damien George0c36da02014-03-08 15:24:39 +0000118MATH_FUN_1(atan, atan)
Damien George30dd23a2014-08-10 17:50:28 +0100119/// \function atan2(y, x)
Damien George0c36da02014-03-08 15:24:39 +0000120MATH_FUN_2(atan2, atan2)
Damien George30dd23a2014-08-10 17:50:28 +0100121/// \function ceil(x)
Damien George084ef372014-04-01 21:21:50 +0100122MATH_FUN_1_TO_INT(ceil, ceil)
Damien George30dd23a2014-08-10 17:50:28 +0100123/// \function copysign(x, y)
Rachel Dowdall5a14a1d2014-03-20 21:26:51 +0000124MATH_FUN_2(copysign, copysign)
Damien George30dd23a2014-08-10 17:50:28 +0100125/// \function fabs(x)
Rachel Dowdall5a14a1d2014-03-20 21:26:51 +0000126MATH_FUN_1(fabs, fabs)
Damien George30dd23a2014-08-10 17:50:28 +0100127/// \function floor(x)
Damien George084ef372014-04-01 21:21:50 +0100128MATH_FUN_1_TO_INT(floor, floor) //TODO: delegate to x.__floor__() if x is not a float
Damien George30dd23a2014-08-10 17:50:28 +0100129/// \function fmod(x, y)
Rachel Dowdall5a14a1d2014-03-20 21:26:51 +0000130MATH_FUN_2(fmod, fmod)
Damien George30dd23a2014-08-10 17:50:28 +0100131/// \function isfinite(x)
Damien George084ef372014-04-01 21:21:50 +0100132MATH_FUN_1_TO_BOOL(isfinite, isfinite)
Damien George30dd23a2014-08-10 17:50:28 +0100133/// \function isinf(x)
Damien George084ef372014-04-01 21:21:50 +0100134MATH_FUN_1_TO_BOOL(isinf, isinf)
Damien George30dd23a2014-08-10 17:50:28 +0100135/// \function isnan(x)
Damien George084ef372014-04-01 21:21:50 +0100136MATH_FUN_1_TO_BOOL(isnan, isnan)
Damien George30dd23a2014-08-10 17:50:28 +0100137/// \function trunc(x)
Damien George084ef372014-04-01 21:21:50 +0100138MATH_FUN_1_TO_INT(trunc, trunc)
Damien George30dd23a2014-08-10 17:50:28 +0100139/// \function ldexp(x, exp)
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000140MATH_FUN_2(ldexp, ldexp)
Damien George5cbeace2015-02-22 14:48:18 +0000141#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
Damien George30dd23a2014-08-10 17:50:28 +0100142/// \function erf(x)
143/// Return the error function of `x`.
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000144MATH_FUN_1(erf, erf)
Damien George30dd23a2014-08-10 17:50:28 +0100145/// \function erfc(x)
146/// Return the complementary error function of `x`.
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000147MATH_FUN_1(erfc, erfc)
Damien George30dd23a2014-08-10 17:50:28 +0100148/// \function gamma(x)
149/// Return the gamma function of `x`.
xbe1ea8fcf2014-03-23 02:46:10 -0700150MATH_FUN_1(gamma, tgamma)
Damien George30dd23a2014-08-10 17:50:28 +0100151/// \function lgamma(x)
152/// return the natural logarithm of the gamma function of `x`.
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000153MATH_FUN_1(lgamma, lgamma)
Damien George5cbeace2015-02-22 14:48:18 +0000154#endif
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000155//TODO: factorial, fsum
Rachel Dowdalla2f2f732014-03-20 21:30:38 +0000156
Damien George6f495202015-06-13 21:56:23 +0100157// Function that takes a variable number of arguments
158
159// log(x[, base])
Damien George4b72b3a2016-01-03 14:21:40 +0000160STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
Michael Buesch17298af2015-12-10 13:28:37 +0100161 mp_float_t x = mp_obj_get_float(args[0]);
162 if (x <= (mp_float_t)0.0) {
163 math_error();
164 }
165 mp_float_t l = MICROPY_FLOAT_C_FUN(log)(x);
Damien George6f495202015-06-13 21:56:23 +0100166 if (n_args == 1) {
167 return mp_obj_new_float(l);
168 } else {
Michael Buesch17298af2015-12-10 13:28:37 +0100169 mp_float_t base = mp_obj_get_float(args[1]);
170 if (base <= (mp_float_t)0.0) {
171 math_error();
172 }
173 return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
Damien George6f495202015-06-13 21:56:23 +0100174 }
175}
176STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log);
177
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000178// Functions that return a tuple
Damien George30dd23a2014-08-10 17:50:28 +0100179
180/// \function frexp(x)
181/// Converts a floating-point number to fractional and integral components.
Damien George969a6b32014-12-10 22:07:04 +0000182STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
Damien George62805872014-03-22 20:44:15 +0000183 int int_exponent = 0;
184 mp_float_t significand = MICROPY_FLOAT_C_FUN(frexp)(mp_obj_get_float(x_obj), &int_exponent);
185 mp_obj_t tuple[2];
186 tuple[0] = mp_obj_new_float(significand);
187 tuple[1] = mp_obj_new_int(int_exponent);
188 return mp_obj_new_tuple(2, tuple);
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000189}
190STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp);
191
Damien George30dd23a2014-08-10 17:50:28 +0100192/// \function modf(x)
Damien George969a6b32014-12-10 22:07:04 +0000193STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) {
Damien George62805872014-03-22 20:44:15 +0000194 mp_float_t int_part = 0.0;
195 mp_float_t fractional_part = MICROPY_FLOAT_C_FUN(modf)(mp_obj_get_float(x_obj), &int_part);
196 mp_obj_t tuple[2];
197 tuple[0] = mp_obj_new_float(fractional_part);
198 tuple[1] = mp_obj_new_float(int_part);
199 return mp_obj_new_tuple(2, tuple);
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000200}
201STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf);
202
203// Angular conversions
Damien George30dd23a2014-08-10 17:50:28 +0100204
205/// \function radians(x)
Damien George969a6b32014-12-10 22:07:04 +0000206STATIC mp_obj_t mp_math_radians(mp_obj_t x_obj) {
Damien George62805872014-03-22 20:44:15 +0000207 return mp_obj_new_float(mp_obj_get_float(x_obj) * M_PI / 180.0);
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000208}
209STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians);
210
Damien George30dd23a2014-08-10 17:50:28 +0100211/// \function degrees(x)
Damien George969a6b32014-12-10 22:07:04 +0000212STATIC mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
Damien George62805872014-03-22 20:44:15 +0000213 return mp_obj_new_float(mp_obj_get_float(x_obj) * 180.0 / M_PI);
Rachel Dowdall249b9c72014-03-22 14:39:33 +0000214}
215STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees);
216
Damien Georgecbf76742015-11-27 13:38:15 +0000217STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = {
218 { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_math) },
219 { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e },
220 { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi },
221 { MP_ROM_QSTR(MP_QSTR_sqrt), MP_ROM_PTR(&mp_math_sqrt_obj) },
222 { MP_ROM_QSTR(MP_QSTR_pow), MP_ROM_PTR(&mp_math_pow_obj) },
223 { MP_ROM_QSTR(MP_QSTR_exp), MP_ROM_PTR(&mp_math_exp_obj) },
Paul Sokolovsky863d4cd2015-11-14 00:55:54 +0200224 #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
Damien Georgecbf76742015-11-27 13:38:15 +0000225 { MP_ROM_QSTR(MP_QSTR_expm1), MP_ROM_PTR(&mp_math_expm1_obj) },
Paul Sokolovsky863d4cd2015-11-14 00:55:54 +0200226 #endif
Damien Georgecbf76742015-11-27 13:38:15 +0000227 { MP_ROM_QSTR(MP_QSTR_log), MP_ROM_PTR(&mp_math_log_obj) },
Damien Georgea24eafa2015-11-17 14:10:13 +0000228 #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
Damien Georgecbf76742015-11-27 13:38:15 +0000229 { MP_ROM_QSTR(MP_QSTR_log2), MP_ROM_PTR(&mp_math_log2_obj) },
230 { MP_ROM_QSTR(MP_QSTR_log10), MP_ROM_PTR(&mp_math_log10_obj) },
231 { MP_ROM_QSTR(MP_QSTR_cosh), MP_ROM_PTR(&mp_math_cosh_obj) },
232 { MP_ROM_QSTR(MP_QSTR_sinh), MP_ROM_PTR(&mp_math_sinh_obj) },
233 { MP_ROM_QSTR(MP_QSTR_tanh), MP_ROM_PTR(&mp_math_tanh_obj) },
234 { MP_ROM_QSTR(MP_QSTR_acosh), MP_ROM_PTR(&mp_math_acosh_obj) },
235 { MP_ROM_QSTR(MP_QSTR_asinh), MP_ROM_PTR(&mp_math_asinh_obj) },
236 { MP_ROM_QSTR(MP_QSTR_atanh), MP_ROM_PTR(&mp_math_atanh_obj) },
Damien Georgea24eafa2015-11-17 14:10:13 +0000237 #endif
Damien Georgecbf76742015-11-27 13:38:15 +0000238 { MP_ROM_QSTR(MP_QSTR_cos), MP_ROM_PTR(&mp_math_cos_obj) },
239 { MP_ROM_QSTR(MP_QSTR_sin), MP_ROM_PTR(&mp_math_sin_obj) },
240 { MP_ROM_QSTR(MP_QSTR_tan), MP_ROM_PTR(&mp_math_tan_obj) },
241 { MP_ROM_QSTR(MP_QSTR_acos), MP_ROM_PTR(&mp_math_acos_obj) },
242 { MP_ROM_QSTR(MP_QSTR_asin), MP_ROM_PTR(&mp_math_asin_obj) },
243 { MP_ROM_QSTR(MP_QSTR_atan), MP_ROM_PTR(&mp_math_atan_obj) },
244 { MP_ROM_QSTR(MP_QSTR_atan2), MP_ROM_PTR(&mp_math_atan2_obj) },
245 { MP_ROM_QSTR(MP_QSTR_ceil), MP_ROM_PTR(&mp_math_ceil_obj) },
246 { MP_ROM_QSTR(MP_QSTR_copysign), MP_ROM_PTR(&mp_math_copysign_obj) },
247 { MP_ROM_QSTR(MP_QSTR_fabs), MP_ROM_PTR(&mp_math_fabs_obj) },
248 { MP_ROM_QSTR(MP_QSTR_floor), MP_ROM_PTR(&mp_math_floor_obj) },
249 { MP_ROM_QSTR(MP_QSTR_fmod), MP_ROM_PTR(&mp_math_fmod_obj) },
250 { MP_ROM_QSTR(MP_QSTR_frexp), MP_ROM_PTR(&mp_math_frexp_obj) },
251 { MP_ROM_QSTR(MP_QSTR_ldexp), MP_ROM_PTR(&mp_math_ldexp_obj) },
252 { MP_ROM_QSTR(MP_QSTR_modf), MP_ROM_PTR(&mp_math_modf_obj) },
253 { MP_ROM_QSTR(MP_QSTR_isfinite), MP_ROM_PTR(&mp_math_isfinite_obj) },
254 { MP_ROM_QSTR(MP_QSTR_isinf), MP_ROM_PTR(&mp_math_isinf_obj) },
255 { MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_math_isnan_obj) },
256 { MP_ROM_QSTR(MP_QSTR_trunc), MP_ROM_PTR(&mp_math_trunc_obj) },
257 { MP_ROM_QSTR(MP_QSTR_radians), MP_ROM_PTR(&mp_math_radians_obj) },
258 { MP_ROM_QSTR(MP_QSTR_degrees), MP_ROM_PTR(&mp_math_degrees_obj) },
Damien George5cbeace2015-02-22 14:48:18 +0000259 #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
Damien Georgecbf76742015-11-27 13:38:15 +0000260 { MP_ROM_QSTR(MP_QSTR_erf), MP_ROM_PTR(&mp_math_erf_obj) },
261 { MP_ROM_QSTR(MP_QSTR_erfc), MP_ROM_PTR(&mp_math_erfc_obj) },
262 { MP_ROM_QSTR(MP_QSTR_gamma), MP_ROM_PTR(&mp_math_gamma_obj) },
263 { MP_ROM_QSTR(MP_QSTR_lgamma), MP_ROM_PTR(&mp_math_lgamma_obj) },
Damien George5cbeace2015-02-22 14:48:18 +0000264 #endif
Damien George0c36da02014-03-08 15:24:39 +0000265};
266
Damien George3b603f22014-11-29 14:39:27 +0000267STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table);
Damien George0c36da02014-03-08 15:24:39 +0000268
269const mp_obj_module_t mp_module_math = {
270 .base = { &mp_type_module },
Damien George8b0535e2014-04-05 21:53:54 +0100271 .globals = (mp_obj_dict_t*)&mp_module_math_globals,
Damien George0c36da02014-03-08 15:24:39 +0000272};
273
Damien Georgefb510b32014-06-01 13:32:54 +0100274#endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH