Damien George
561844f3ba
py: Add MICROPY_FLOAT_CONST macro for defining float constants.
All float constants in the core should use this macro to prevent
unnecessary creation of double-precision floats, which makes code less
efficient.
8 years ago
Damien George
93c4a6a3f7
all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
8 years ago
Colin Hogben
a896951a9a
py/objfloat, py/modmath: Ensure M_PI and M_E defined.
In some compliation enviroments (e.g. mbed online compiler) with
strict standards compliance, <math.h> does not define constants such
as M_PI. Provide fallback definitions of M_E and M_PI where needed.
9 years ago
Damien George
4b72b3a133
py: Change type signature of builtin funs that take variable or kw args.
With this patch the n_args parameter is changed type from mp_uint_t to
size_t.
9 years ago
Michael Buesch
17298af61e
py/modmath: Add domain error checking to sqrt, log, log2, log10.
These functions will raise 'ValueError: math domain error' on invalid
input.
9 years ago
Damien George
cbf7674025
py: Add MP_ROM_* macros and mp_rom_* types and use them.
9 years ago
Damien George
a24eafacc9
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).
9 years ago
Paul Sokolovsky
863d4cd862
py/modmath: Don't create symbol entry for expm1() if not needed.
9 years ago
Paul Sokolovsky
0d6116d86b
py/modmath: Make expm1() be in MICROPY_PY_MATH_SPECIAL_FUNCTIONS.
9 years ago
Paul Sokolovsky
6d1eabfeaa
unix/mpconfigport: Move log2() definition to modmath.c.
It's safer to define it where it's used, defining it for all source files
may lead to hard to diagnose conflicts in corner cases.
9 years ago
Damien George
7e359c648b
py: Move float e/pi consts to objfloat and make mp_obj_float_t private.
9 years ago
Paul Sokolovsky
1b586f3a73
py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming.
9 years ago
Damien George
6f49520042
py: Implement second arg for math.log (optional value for base).
10 years ago
Damien George
5cbeacebdb
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.
10 years ago
Damien George
51dfcb4bb7
py: Move to guarded includes, everywhere in py/ core.
Addresses issue #1022 .
10 years ago
Damien George
969a6b37bf
py: Make functions static where appropriate.
10 years ago
Damien George
3b603f29ec
Use MP_DEFINE_CONST_DICT macro to define module dicts.
This is just a clean-up of the code. Generated code is exactly the
same.
10 years ago
Damien George
30dd23aa7f
doc: Document gc, sys, math, cmath.
10 years ago
Damien George
40f3c02682
Rename machine_(u)int_t to mp_(u)int_t.
See discussion in issue #50 .
11 years ago
Paul Sokolovsky
59c675a64c
py: Include mpconfig.h before all other includes.
It defines types used by all other headers.
Fixes #691 .
11 years ago
Emmanuel Blot
f6932d6506
Prefix ARRAY_SIZE with micropython prefix MP_
11 years ago
Damien George
fb510b3bf9
Rename bultins config variables to MICROPY_PY_BUILTINS_*.
This renames:
MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET
MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY
MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE
MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT
See issue #35 for discussion.
11 years ago
Damien George
ee3fd46f13
Rename configuration variables controling Python features.
Now of the form MICROPY_PY_*. See issue #35 .
11 years ago
Antonin ENFRUN
da1fffaa09
Fix some unused variables, and silence a clang warning about initialization override in vmentrytable.h
11 years ago
Damien George
04b9147e15
Add license header to (almost) all files.
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
11 years ago
Damien George
6d3c5e4301
Add ARRAY_SIZE macro, and use it where possible.
11 years ago
Damien George
dbdfee15a1
py: Add cmath module, for complex math. Disabled by default.
Not all functions implemented. Not enabled on pyboard.
11 years ago
Damien George
8b0535e23f
py: Change module globals from mp_map_t* to mp_obj_dict_t*.
Towards addressing issue #424 .
Had a small increase to ROM usage (order 60 bytes).
11 years ago
Damien George
084ef373fb
py: Fix math.{ceil,floor,trunc} to return int.
11 years ago
Damien George
df6567e634
Merge map.h into obj.h.
Pretty much everyone needs to include map.h, since it's such an integral
part of the Micro Python object implementation. Thus, the definitions
are now in obj.h instead. map.h is removed.
11 years ago
Damien George
caac542b23
Proper support for registering builtin modules in ROM.
Comes with some refactoring of code and renaming of files. All modules
are now named mod*.[ch].
11 years ago
xbe
1ea8fcfae4
py/builtinmath.c: use tgamma() instead of gamma().
gamma() is now deprecated.
11 years ago
Damien George
6280587320
py: Fix types in new math functions.
11 years ago
Rachel Dowdall
249b9c761d
Fixed broken math functions that return bool and added some more.
11 years ago
Damien George
c070ff24a9
Disable some math functions until they work correctly.
11 years ago
Rachel Dowdall
a2f2f734ed
Added various simple functions to math module.
11 years ago
Rachel Dowdall
5a14a1d690
Added various simple functions to math module.
11 years ago
Damien George
a925639247
py: Add math.e constant.
11 years ago
xbe
efe3422394
py: Clean up includes.
Remove unnecessary includes. Add includes that improve portability.
11 years ago
Damien George
8854e1fa05
py: Add expm1 to math module.
11 years ago
Damien George
0c36da0b59
Implement ROMable modules. Add math module.
mp_module_obj_t can now be put in ROM.
Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.
math module has basic math functions. For STM port, these are not yet
implemented (they are just stub functions).
11 years ago