Compare commits
3 commits
2dim
...
fix-undef-
| Author | SHA1 | Date | |
|---|---|---|---|
| 1beddec7bb | |||
| 5e81f75661 | |||
|
|
21b5a130c8 |
12 changed files with 41 additions and 65 deletions
64
README.md
64
README.md
|
|
@ -1,62 +1,12 @@
|
|||
# micropython-ulab
|
||||
# circuitpython-ulab
|
||||
|
||||
ulab is a numpy-like array manipulation library for micropython.
|
||||
The module is written in C, defines compact containers for numerical
|
||||
data, and is fast.
|
||||
data, and is fast.
|
||||
|
||||
Documentation can be found under https://micropython-ulab.readthedocs.io/en/latest/
|
||||
The source for the manual is in https://github.com/v923z/micropython-ulab/blob/master/docs/ulab-manual.ipynb,
|
||||
while developer help is in https://github.com/v923z/micropython-ulab/blob/master/docs/ulab.ipynb.
|
||||
ulab will be incorporated in builds of most CircuitPython supported
|
||||
devices, so there's usually no need to use the files here directly.
|
||||
If you've encountered a problem with circuitpython-ulab, please
|
||||
file an issue [in the circuitpython issue tracker](https://github.com/adafruit/circuitpython).
|
||||
|
||||
# Firmware
|
||||
|
||||
Firmware for pyboard.v.1.1, and PYBD_SF6 is updated once in a while, and can be downloaded
|
||||
from https://github.com/v923z/micropython-ulab/releases.
|
||||
|
||||
## Compiling
|
||||
|
||||
If you want to try the latest version of `ulab`, or your hardware is
|
||||
different to pyboard.v.1.1, or PYBD_SF6, the firmware can be compiled
|
||||
from the source by following these steps:
|
||||
|
||||
First, you have to clone the micropython repository by running
|
||||
|
||||
```
|
||||
git clone https://github.com/micropython/micropython.git
|
||||
```
|
||||
on the command line. This will create a new repository with the name `micropython`. Staying there, clone the `ulab` repository with
|
||||
|
||||
```
|
||||
git clone https://github.com/v923z/micropython-ulab.git ulab
|
||||
```
|
||||
|
||||
Then you have to include `ulab` in the compilation process by editing `mpconfigport.h` of the directory of the port for which you want to compile, so, still on the command line, navigate to `micropython/ports/unix`, or `micropython/ports/stm32`, or whichever port is your favourite, and edit the `mpconfigport.h` file there. All you have to do is add a single line at the end:
|
||||
|
||||
```
|
||||
#define MODULE_ULAB_ENABLED (1)
|
||||
```
|
||||
|
||||
This line will inform the compiler that you want `ulab` in the resulting firmware. If you don't have the cross-compiler installed, your might want to do that now, for instance on Linux by executing
|
||||
|
||||
```
|
||||
sudo apt-get install gcc-arm-none-eabi
|
||||
```
|
||||
If that was successful, you can try to run the make command in the port's directory as
|
||||
```
|
||||
make BOARD=PYBV11 USER_C_MODULES=../../../ulab all
|
||||
```
|
||||
which will prepare the firmware for pyboard.v.11. Similarly,
|
||||
```
|
||||
make BOARD=PYBD_SF6 USER_C_MODULES=../../../ulab all
|
||||
```
|
||||
will compile for the SF6 member of the PYBD series. Provided that you managed to compile the firmware, you would upload that by running
|
||||
either
|
||||
```
|
||||
dfu-util --alt 0 -D firmware.dfu
|
||||
```
|
||||
or
|
||||
```
|
||||
python pydfu.py -u firmware.dfu
|
||||
```
|
||||
|
||||
In case you got stuck somewhere in the process, a bit more detailed instructions can be found under https://github.com/micropython/micropython/wiki/Getting-Started, and https://github.com/micropython/micropython/wiki/Pyboard-Firmware-Update.
|
||||
circuitpython-ulab is based on [micropython-ulab](https://github.com/v923z/micropython-ulab).
|
||||
|
|
|
|||
14
code/compat.h
Normal file
14
code/compat.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef MICROPY_INCLUDED_ULAB_COMPAT_H
|
||||
#define MICROPY_INCLUDED_ULAB_COMPAT_H
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
|
||||
#define mp_obj_is_type(obj, type) MP_OBJ_IS_TYPE(obj, type)
|
||||
#define mp_obj_is_int(obj) MP_OBJ_IS_INT(obj)
|
||||
|
||||
#define MP_ROM_NONE (MP_ROM_PTR(&mp_const_none_obj))
|
||||
#define MP_ROM_FALSE (mp_const_false)
|
||||
#define MP_ROM_TRUE (mp_const_true)
|
||||
|
||||
#endif // MICROPY_INCLUDED_ULAB_COMPAT_H
|
||||
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include "py/binary.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/objarray.h"
|
||||
#include "compat.h"
|
||||
#include "ndarray.h"
|
||||
#include "fft.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/misc.h"
|
||||
#include "compat.h"
|
||||
#include "filter.h"
|
||||
|
||||
#if ULAB_FILTER_CONVOLVE
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/misc.h"
|
||||
#include "compat.h"
|
||||
#include "linalg.h"
|
||||
|
||||
#if ULAB_LINALG_TRANSPOSE
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "py/binary.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/objtuple.h"
|
||||
#include "compat.h"
|
||||
#include "ndarray.h"
|
||||
|
||||
// This function is copied verbatim from objarray.c
|
||||
|
|
@ -165,11 +166,14 @@ STATIC uint8_t ndarray_init_helper(size_t n_args, const mp_obj_t *pos_args, mp_m
|
|||
return dtype;
|
||||
}
|
||||
|
||||
mp_obj_t ndarray_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 2, true);
|
||||
mp_map_t kw_args;
|
||||
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
|
||||
uint8_t dtype = ndarray_init_helper(n_args, args, &kw_args);
|
||||
mp_obj_t ndarray_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 1, 2, true);
|
||||
size_t n_kw = 0;
|
||||
if (kw_args != 0) {
|
||||
n_kw = kw_args->used;
|
||||
}
|
||||
mp_map_init_fixed_table(kw_args, n_kw, args + n_args);
|
||||
uint8_t dtype = ndarray_init_helper(n_args, args, kw_args);
|
||||
|
||||
size_t len1, len2=0, i=0;
|
||||
mp_obj_t len_in = mp_obj_len_maybe(args[0]);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void ndarray_assign_elements(mp_obj_array_t *, mp_obj_t , uint8_t , size_t *);
|
|||
ndarray_obj_t *create_new_ndarray(size_t , size_t , uint8_t );
|
||||
|
||||
mp_obj_t ndarray_copy(mp_obj_t );
|
||||
mp_obj_t ndarray_make_new(const mp_obj_type_t *, size_t , size_t , const mp_obj_t *);
|
||||
mp_obj_t ndarray_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args);
|
||||
mp_obj_t ndarray_subscr(mp_obj_t , mp_obj_t , mp_obj_t );
|
||||
mp_obj_t ndarray_getiter(mp_obj_t , mp_obj_iter_buf_t *);
|
||||
mp_obj_t ndarray_binary_op(mp_binary_op_t , mp_obj_t , mp_obj_t );
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "py/runtime.h"
|
||||
#include "py/builtin.h"
|
||||
#include "py/misc.h"
|
||||
#include "compat.h"
|
||||
#include "numerical.h"
|
||||
|
||||
enum NUMERICAL_FUNCTION_TYPE {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/objarray.h"
|
||||
#include "compat.h"
|
||||
#include "ndarray.h"
|
||||
#include "linalg.h"
|
||||
#include "poly.h"
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include "py/objarray.h"
|
||||
|
||||
#include "ulab.h"
|
||||
#include "compat.h"
|
||||
#include "ndarray.h"
|
||||
#include "linalg.h"
|
||||
#include "vectorise.h"
|
||||
|
|
@ -146,7 +147,7 @@ STATIC const mp_map_elem_t ulab_globals_table[] = {
|
|||
#if ULAB_VECTORISE_SIN
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_sin), (mp_obj_t)&vectorise_sin_obj },
|
||||
#endif
|
||||
#if ULAB_VECTORISE_
|
||||
#if ULAB_VECTORISE_SINH
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_sinh), (mp_obj_t)&vectorise_sinh_obj },
|
||||
#endif
|
||||
#if ULAB_VECTORISE_SQRT
|
||||
|
|
@ -155,7 +156,7 @@ STATIC const mp_map_elem_t ulab_globals_table[] = {
|
|||
#if ULAB_VECTORISE_TAN
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_tan), (mp_obj_t)&vectorise_tan_obj },
|
||||
#endif
|
||||
#if ULAB_VECTORISE_TAHN
|
||||
#if ULAB_VECTORISE_TANH
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_tanh), (mp_obj_t)&vectorise_tanh_obj },
|
||||
#endif
|
||||
#if ULAB_NUMERICAL_LINSPACE
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
#define ULAB_POLY_POLYFIT (1)
|
||||
|
||||
//
|
||||
#define ULAB_NUMERICAL_ARGSORT (1)
|
||||
#define ULAB_NUMERICAL_LINSPACE (1)
|
||||
#define ULAB_NUMERICAL_SUM (1)
|
||||
#define ULAB_NUMERICAL_MEAN (1)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "py/binary.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/objarray.h"
|
||||
#include "compat.h"
|
||||
#include "vectorise.h"
|
||||
|
||||
#ifndef MP_PI
|
||||
|
|
|
|||
Loading…
Reference in a new issue