micropython/py
Christopher Swenson 8c656754aa py/modmath: Add math.factorial, optimised and non-opt implementations.
This commit adds the math.factorial function in two variants:
- squared difference, which is faster than the naive version, relatively
  compact, and non-recursive;
- a mildly optimised recursive version, faster than the above one.

There are some more optimisations that could be done, but they tend to take
more code, and more storage space.  The recursive version seems like a
sensible compromise.

The new function is disabled by default, and uses the non-optimised version
by default if it is enabled.  The options are MICROPY_PY_MATH_FACTORIAL
and MICROPY_OPT_MATH_FACTORIAL.
2018-09-26 15:03:04 +10:00
..
argcheck.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
asmarm.c py/asm*: Support assembling code to jump to a register, and get PC+off. 2018-08-16 13:45:24 +10:00
asmarm.h py/asm*: Support assembling code to jump to a register, and get PC+off. 2018-08-16 13:45:24 +10:00
asmbase.c
asmbase.h
asmthumb.c py/asmthumb: Detect presence of I-cache using CMSIS macro. 2018-09-16 01:50:45 +10:00
asmthumb.h py/asm*: Support assembling code to jump to a register, and get PC+off. 2018-08-16 13:45:24 +10:00
asmx64.c py/{asmx86,asmx64}: Extend test_r8_with_r8 to accept all 8 lower regs. 2018-09-14 17:38:09 +10:00
asmx64.h py/asm*: Support assembling code to jump to a register, and get PC+off. 2018-08-16 13:45:24 +10:00
asmx86.c py/{asmx86,asmx64}: Extend test_r8_with_r8 to accept all 8 lower regs. 2018-09-14 17:38:09 +10:00
asmx86.h py/asm*: Support assembling code to jump to a register, and get PC+off. 2018-08-16 13:45:24 +10:00
asmxtensa.c py/asmxtensa: Make indirect calls using func table, not raw pointers. 2018-09-16 00:43:24 +10:00
asmxtensa.h py/asmxtensa: Make indirect calls using func table, not raw pointers. 2018-09-16 00:43:24 +10:00
bc.c
bc.h
bc0.h
binary.c
binary.h
builtin.h
builtinevex.c
builtinhelp.c py: Simplify some cases of accessing the map of module and type dict. 2018-07-08 21:31:09 +10:00
builtinimport.c
compile.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
compile.h py/emit: Move MP_EMIT_OPT_xxx enums from compile.h to emitglue.h. 2018-09-15 12:17:09 +10:00
emit.h py/emit: Completely remove set_native_type, arg type is set in compiler. 2018-09-15 13:00:11 +10:00
emitbc.c py/emit: Completely remove set_native_type, arg type is set in compiler. 2018-09-15 13:00:11 +10:00
emitcommon.c
emitglue.c py: Make viper functions have the same entry signature as native. 2018-09-15 22:39:27 +10:00
emitglue.h py/emit: Move MP_EMIT_OPT_xxx enums from compile.h to emitglue.h. 2018-09-15 12:17:09 +10:00
emitinlinethumb.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
emitinlinextensa.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
emitnarm.c py/emitnative: Add support for return/break/continue in try and with. 2018-09-04 14:31:28 +10:00
emitnative.c py/asmxtensa: Make indirect calls using func table, not raw pointers. 2018-09-16 00:43:24 +10:00
emitnthumb.c py/emitnative: Add support for return/break/continue in try and with. 2018-09-04 14:31:28 +10:00
emitnx64.c py/emitnative: Add support for return/break/continue in try and with. 2018-09-04 14:31:28 +10:00
emitnx86.c py: Make viper functions have the same entry signature as native. 2018-09-15 22:39:27 +10:00
emitnxtensa.c py/emitnative: Add support for return/break/continue in try and with. 2018-09-04 14:31:28 +10:00
formatfloat.c
formatfloat.h
frozenmod.c
frozenmod.h
gc.c py/gc: In gc_alloc, reset n_free var right before search for free mem. 2018-08-14 16:11:21 +10:00
gc.h
grammar.h
lexer.c
lexer.h
makeqstrdata.py
makeqstrdefs.py
makeversionhdr.py
malloc.c py/malloc: Give a compile warning if using finaliser without GC. 2018-07-09 14:40:02 +10:00
map.c py: Fix compiling with debug enabled and make more use of DEBUG_printf. 2018-08-02 14:17:24 +10:00
misc.h
mkenv.mk
mkrules.mk
modarray.c
modbuiltins.c py/modbuiltins: Make oct/hex work when !MICROPY_PY_BUILTINS_STR_OP_MODULO 2018-09-20 14:41:35 +10:00
modcmath.c
modcollections.c
modgc.c
modio.c
modmath.c py/modmath: Add math.factorial, optimised and non-opt implementations. 2018-09-26 15:03:04 +10:00
modmicropython.c
modstruct.c
modsys.c
modthread.c
moduerrno.c
mpconfig.h py/modmath: Add math.factorial, optimised and non-opt implementations. 2018-09-26 15:03:04 +10:00
mperrno.h
mphal.h
mpprint.c
mpprint.h
mpstate.c
mpstate.h
mpthread.h
mpz.c
mpz.h
nativeglue.c py: Make viper functions have the same entry signature as native. 2018-09-15 22:39:27 +10:00
nlr.c
nlr.h
nlrsetjmp.c
nlrthumb.c
nlrx64.c
nlrx86.c
nlrxtensa.c
obj.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
obj.h py: Optimise call to mp_arg_check_num by compressing fun signature. 2018-09-14 13:39:17 +10:00
objarray.c py/objarray: bytearray: Allow 2nd/3rd arg to constructor. 2018-09-11 15:10:10 +10:00
objarray.h
objattrtuple.c
objbool.c
objboundmeth.c
objcell.c
objclosure.c
objcomplex.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
objdeque.c
objdict.c py/objdict: Make mp_obj_dict_get_map an inline function. 2018-07-08 22:27:05 +10:00
objenumerate.c
objexcept.c
objexcept.h
objfilter.c
objfloat.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
objfun.c py: Make viper functions have the same entry signature as native. 2018-09-15 22:39:27 +10:00
objfun.h py/objgenerator: Implement __name__ with normal fun attr accessor code. 2018-07-10 16:33:57 +10:00
objgenerator.c py/objgenerator: Implement PEP479, StopIteration convs to RuntimeError. 2018-09-20 15:36:59 +10:00
objgenerator.h
objgetitemiter.c
objint.c
objint.h
objint_longlong.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
objint_mpz.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
objlist.c
objlist.h
objmap.c
objmodule.c py/objmodule: Make mp_obj_module_get_globals an inline function. 2018-07-08 22:27:39 +10:00
objmodule.h
objnamedtuple.c
objnamedtuple.h
objnone.c
objobject.c
objpolyiter.c
objproperty.c
objrange.c
objreversed.c
objset.c
objsingleton.c
objslice.c
objstr.c py/objstr: Make % (__mod__) formatting operator configurable. 2018-09-20 14:41:08 +10:00
objstr.h
objstringio.c
objstringio.h
objstrunicode.c
objtuple.c
objtuple.h
objtype.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
objtype.h
objzip.c
opmethods.c
parse.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
parse.h
parsenum.c py/parsenum: Avoid rounding errors with negative powers-of-10. 2018-09-20 22:06:41 +10:00
parsenum.h
parsenumbase.c
parsenumbase.h
persistentcode.c
persistentcode.h
py.mk py/py.mk: Build axtls library directly from its source files. 2018-09-08 00:07:23 +10:00
pystack.c
pystack.h
qstr.c
qstr.h
qstrdefs.h py/modbuiltins: Make oct/hex work when !MICROPY_PY_BUILTINS_STR_OP_MODULO 2018-09-20 14:41:35 +10:00
reader.c
reader.h
repl.c
repl.h
ringbuf.h
runtime.c py: Shorten error messages by using contractions and some rewording. 2018-09-20 14:33:10 +10:00
runtime.h py: Optimise call to mp_arg_check_num by compressing fun signature. 2018-09-14 13:39:17 +10:00
runtime0.h py: Make viper functions have the same entry signature as native. 2018-09-15 22:39:27 +10:00
runtime_utils.c
scheduler.c
scope.c
scope.h py/emit: Completely remove set_native_type, arg type is set in compiler. 2018-09-15 13:00:11 +10:00
sequence.c
showbc.c
smallint.c
smallint.h
stackctrl.c
stackctrl.h
stream.c py/stream: Adjust mp_stream_posix_XXX to take void*, not mp_obj_t. 2018-08-14 17:36:08 +10:00
stream.h py/stream: Adjust mp_stream_posix_XXX to take void*, not mp_obj_t. 2018-08-14 17:36:08 +10:00
unicode.c
unicode.h
vm.c py/vm: Fix handling of finally-return with complex nested finallys. 2018-09-03 13:08:16 +10:00
vmentrytable.h
vstr.c
warning.c