circuitpython-ulab/code
Jeff Epler 3dc52575f0 slice_length: avoid implementation-defined division by negative number
In CircuitPython (only), a the slice assignment to [-1👎-3] of an
ndarray of length 1 caused a crash.  This appears to be because in
CircuitPython, the internal pointer of an empty array was NULL rather than
pointing at some memory which happened to be valid and assignable.

This appears to be a corner case of how integer promotion rules work in C.
The expression `slice.stop - slice.start + (slice.step + correction)`
is type `unsigned long` and on a LP64 platform its value is
18446744073709551614.  This led to the function returning that this slice
had length 1 instead, during the automated tests.

By casting to signed types capable of holding indices and sizes, the
problem is corrected on both platforms.
2020-03-16 22:09:39 -05:00
..
create.c added new source file... 2020-02-27 20:46:52 +01:00
create.h Always include creation functions 2020-02-27 14:07:04 -06:00
extras.c re-named spectrum->spectrogram, updated manual 2020-03-10 21:11:44 +01:00
extras.h moved spectrum to extras module 2020-03-09 20:47:58 +01:00
fft.c moved spectrum to extras module 2020-03-09 20:47:58 +01:00
fft.h moved spectrum to extras module 2020-03-09 20:47:58 +01:00
filter.c Remove CIRCUITPY special cases 2020-02-27 08:56:07 -06:00
filter.h roll back constness corrections 2020-02-18 21:00:30 -06:00
linalg.c added Cholesky decomposition to linalg.c, updated documentation 2020-03-10 20:40:11 +01:00
linalg.h added function declarations to linalg.h 2020-03-09 21:22:31 +01:00
micropython.mk created new create sub-module for ndarray initialisation functions 2020-02-27 20:39:13 +01:00
ndarray.c slice_length: avoid implementation-defined division by negative number 2020-03-16 22:09:39 -05:00
ndarray.h properties are now defined in ndarray_properties.h 2020-02-16 19:49:01 +01:00
ndarray_properties.h Use circuitpy-compat for none 2020-02-27 08:56:04 -06:00
numerical.c created new create sub-module for ndarray initialisation functions 2020-02-27 20:39:13 +01:00
numerical.h created new create sub-module for ndarray initialisation functions 2020-02-27 20:39:13 +01:00
poly.c Remove CIRCUITPY special cases 2020-02-27 08:56:07 -06:00
poly.h roll back constness corrections 2020-02-18 21:00:30 -06:00
ulab.c added around to vectorise.c, and implemented array initialiation from another ndarray 2020-03-12 17:28:23 +01:00
ulab.h moved spectrum to extras module 2020-03-09 20:47:58 +01:00
vectorise.c added arctan2 to vectorise.c 2020-03-16 19:36:37 +01:00
vectorise.h properties are now defined in ndarray_properties.h 2020-02-16 19:49:01 +01:00