Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scipy integration #699

Merged
merged 22 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/micropython.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
USERMODULES_DIR := $(USERMOD_DIR)

# Add all C files to SRC_USERMOD.
SRC_USERMOD += $(USERMODULES_DIR)/scipy/integrate/integrate.c
SRC_USERMOD += $(USERMODULES_DIR)/scipy/linalg/linalg.c
SRC_USERMOD += $(USERMODULES_DIR)/scipy/optimize/optimize.c
SRC_USERMOD += $(USERMODULES_DIR)/scipy/signal/signal.c
Expand Down
701 changes: 701 additions & 0 deletions code/scipy/integrate/integrate.c

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions code/scipy/integrate/integrate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

/*
* This file is part of the micropython-ulab project,
*
* https://github.com/v923z/micropython-ulab
*
* The MIT License (MIT)
*
* Copyright (c) 2024 Harald Milz <[email protected]>
*
*/

#ifndef _SCIPY_INTEGRATE_
#define _SCIPY_INTEGRATE_

#include "../../ulab_tools.h"

extern const mp_obj_module_t ulab_scipy_integrate_module;

#if ULAB_INTEGRATE_HAS_TANHSINH
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_tanhsinh_obj);
#endif
#if ULAB_INTEGRATE_HAS_ROMBERG
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_romberg_obj);
#endif
#if ULAB_INTEGRATE_HAS_SIMPSON
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_simpson_obj);
#endif
#if ULAB_INTEGRATE_HAS_QUAD
MP_DECLARE_CONST_FUN_OBJ_KW(optimize_quad_obj);
#endif

#endif /* _SCIPY_INTEGRATE_ */

6 changes: 5 additions & 1 deletion code/scipy/scipy.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* This file is part of the micropython-ulab project,
*
Expand All @@ -20,6 +19,8 @@
#include "signal/signal.h"
#include "special/special.h"
#include "linalg/linalg.h"
#include "integrate/integrate.h"


#if ULAB_HAS_SCIPY

Expand All @@ -28,6 +29,9 @@

static const mp_rom_map_elem_t ulab_scipy_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_scipy) },
#if ULAB_SCIPY_HAS_INTEGRATE_MODULE
{ MP_ROM_QSTR(MP_QSTR_integrate), MP_ROM_PTR(&ulab_scipy_integrate_module) },
#endif
#if ULAB_SCIPY_HAS_LINALG_MODULE
{ MP_ROM_QSTR(MP_QSTR_linalg), MP_ROM_PTR(&ulab_scipy_linalg_module) },
#endif
Expand Down
2 changes: 1 addition & 1 deletion code/ulab.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "user/user.h"
#include "utils/utils.h"

#define ULAB_VERSION 6.6.1
#define ULAB_VERSION 6.7.0
#define xstr(s) str(s)
#define str(s) #s

Expand Down
22 changes: 22 additions & 0 deletions code/ulab.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,28 @@
#define ULAB_NUMPY_HAS_WHERE (1)
#endif

// the integrate module; functions of the integrate module still have
// to be defined separately
#ifndef ULAB_SCIPY_HAS_INTEGRATE_MODULE
#define ULAB_SCIPY_HAS_INTEGRATE_MODULE (1)
#endif

#ifndef ULAB_INTEGRATE_HAS_TANHSINH
#define ULAB_INTEGRATE_HAS_TANHSINH (1)
#endif

#ifndef ULAB_INTEGRATE_HAS_ROMBERG
#define ULAB_INTEGRATE_HAS_ROMBERG (1)
#endif

#ifndef ULAB_INTEGRATE_HAS_SIMPSON
#define ULAB_INTEGRATE_HAS_SIMPSON (1)
#endif

#ifndef ULAB_INTEGRATE_HAS_QUAD
#define ULAB_INTEGRATE_HAS_QUAD (1)
#endif

// the linalg module; functions of the linalg module still have
// to be defined separately
#ifndef ULAB_NUMPY_HAS_LINALG_MODULE
Expand Down
Loading
Loading