mxlpy-native 0.2.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. mxlpy_native-0.4.0/LICENSE +21 -0
  2. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/MANIFEST.in +1 -0
  3. mxlpy_native-0.4.0/PKG-INFO +70 -0
  4. mxlpy_native-0.4.0/README.md +46 -0
  5. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/mxn_solvers.c +83 -3
  6. mxlpy_native-0.4.0/c/vendor/SUNDIALS-LICENCE.txt +31 -0
  7. mxlpy_native-0.4.0/c/vendor/SUNDIALS-NOTICE.txt +21 -0
  8. mxlpy_native-0.4.0/c/vendor/VENDORED +92 -0
  9. mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode.h +269 -0
  10. mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode_diag.h +63 -0
  11. mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode_ls.h +134 -0
  12. mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode_proj.h +60 -0
  13. mxlpy_native-0.4.0/c/vendor/sundials/include/nvector/nvector_serial.h +292 -0
  14. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/priv/sundials_context_impl.h +49 -0
  15. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/priv/sundials_errors_impl.h +561 -0
  16. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/priv/sundials_logger_macros.h +136 -0
  17. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_adaptcontroller.h +206 -0
  18. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_adjointcheckpointscheme.h +124 -0
  19. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_adjointstepper.h +84 -0
  20. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_band.h +197 -0
  21. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_config.h +106 -0
  22. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_context.h +71 -0
  23. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_core.h +45 -0
  24. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_dense.h +237 -0
  25. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_direct.h +369 -0
  26. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_domeigestimator.h +156 -0
  27. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_errors.h +133 -0
  28. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_export.h +51 -0
  29. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_futils.h +50 -0
  30. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_iterative.h +485 -0
  31. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_linearsolver.h +252 -0
  32. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_logger.h +120 -0
  33. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_math.h +353 -0
  34. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_matrix.h +169 -0
  35. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_memory.h +187 -0
  36. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_nonlinearsolver.h +248 -0
  37. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_nvector.h +363 -0
  38. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_nvector_senswrapper.h +109 -0
  39. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_profiler.h +105 -0
  40. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_stepper.h +178 -0
  41. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_types.h +284 -0
  42. mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_version.h +44 -0
  43. mxlpy_native-0.4.0/c/vendor/sundials/include/sunlinsol/sunlinsol_dense.h +96 -0
  44. mxlpy_native-0.4.0/c/vendor/sundials/include/sunmatrix/sunmatrix_band.h +138 -0
  45. mxlpy_native-0.4.0/c/vendor/sundials/include/sunmatrix/sunmatrix_dense.h +116 -0
  46. mxlpy_native-0.4.0/c/vendor/sundials/include/sunmatrix/sunmatrix_sparse.h +198 -0
  47. mxlpy_native-0.4.0/c/vendor/sundials/include/sunnonlinsol/sunnonlinsol_fixedpoint.h +159 -0
  48. mxlpy_native-0.4.0/c/vendor/sundials/include/sunnonlinsol/sunnonlinsol_newton.h +154 -0
  49. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode.c +5003 -0
  50. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_diag_impl.h +72 -0
  51. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_fused_stubs.c +163 -0
  52. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_impl.h +800 -0
  53. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_io.c +1841 -0
  54. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_ls.c +1976 -0
  55. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_ls_impl.h +202 -0
  56. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_nls.c +490 -0
  57. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_proj.c +456 -0
  58. mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_proj_impl.h +78 -0
  59. mxlpy_native-0.4.0/c/vendor/sundials/src/nvector/serial/nvector_serial.c +2053 -0
  60. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/stl/sunstl_vector.h +300 -0
  61. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_adiak_metadata.h +152 -0
  62. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_band.c +276 -0
  63. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_context.c +313 -0
  64. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_debug.h +54 -0
  65. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_dense.c +415 -0
  66. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_errors.c +164 -0
  67. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_futils.c +58 -0
  68. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_hashmap_impl.h +87 -0
  69. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_linearsolver.c +345 -0
  70. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_logger.c +625 -0
  71. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_logger_impl.h +167 -0
  72. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_macros.h +44 -0
  73. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_math.c +95 -0
  74. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_matrix.c +250 -0
  75. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_memory.c +262 -0
  76. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_nonlinearsolver.c +391 -0
  77. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_nvector.c +1132 -0
  78. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_nvector_senswrapper.c +569 -0
  79. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_utils.h +146 -0
  80. mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_version.c +64 -0
  81. mxlpy_native-0.4.0/c/vendor/sundials/src/sunlinsol/dense/sunlinsol_dense.c +225 -0
  82. mxlpy_native-0.4.0/c/vendor/sundials/src/sunmatrix/band/sunmatrix_band.c +539 -0
  83. mxlpy_native-0.4.0/c/vendor/sundials/src/sunmatrix/dense/sunmatrix_dense.c +413 -0
  84. mxlpy_native-0.4.0/c/vendor/sundials/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +872 -0
  85. mxlpy_native-0.4.0/c/vendor/sundials/src/sunnonlinsol/newton/sunnonlinsol_newton.c +544 -0
  86. mxlpy_native-0.4.0/pyproject.toml +58 -0
  87. mxlpy_native-0.4.0/setup.py +120 -0
  88. mxlpy_native-0.4.0/src/mxlpy_native/__init__.py +76 -0
  89. mxlpy_native-0.4.0/src/mxlpy_native/__main__.py +35 -0
  90. mxlpy_native-0.4.0/src/mxlpy_native.egg-info/PKG-INFO +70 -0
  91. mxlpy_native-0.4.0/src/mxlpy_native.egg-info/SOURCES.txt +107 -0
  92. mxlpy_native-0.4.0/src/mxlpy_native.egg-info/requires.txt +1 -0
  93. mxlpy_native-0.4.0/tests/test_build_errors.py +48 -0
  94. mxlpy_native-0.4.0/tests/test_solvers.py +63 -0
  95. mxlpy_native-0.4.0/tests/test_vendor.py +32 -0
  96. mxlpy_native-0.2.0/PKG-INFO +0 -6
  97. mxlpy_native-0.2.0/README.md +0 -5
  98. mxlpy_native-0.2.0/c/vendor/VENDORED +0 -13
  99. mxlpy_native-0.2.0/pyproject.toml +0 -18
  100. mxlpy_native-0.2.0/setup.py +0 -26
  101. mxlpy_native-0.2.0/src/mxlpy_native/__init__.py +0 -18
  102. mxlpy_native-0.2.0/src/mxlpy_native.egg-info/PKG-INFO +0 -6
  103. mxlpy_native-0.2.0/src/mxlpy_native.egg-info/SOURCES.txt +0 -22
  104. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/HAIRER-LICENCE.txt +0 -0
  105. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/SCIPY-LICENCE.txt +0 -0
  106. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/blaslapack_declarations.h +0 -0
  107. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/dc_decsol.c +0 -0
  108. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/decsol.c +0 -0
  109. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/f2c.h +0 -0
  110. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/libf2c_stubs.c +0 -0
  111. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/lsoda.c +0 -0
  112. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/lsoda.h +0 -0
  113. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/mxs_lapack.c +0 -0
  114. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/c/vendor/radau5.c +0 -0
  115. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/setup.cfg +0 -0
  116. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/src/mxlpy_native.egg-info/dependency_links.txt +0 -0
  117. {mxlpy_native-0.2.0 → mxlpy_native-0.4.0}/src/mxlpy_native.egg-info/top_level.txt +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2025] [Marvin van Aalst, Anna Matuszyńska]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1 +1,2 @@
1
1
  include c/*.c c/vendor/*.c c/vendor/*.h c/vendor/*.txt c/vendor/VENDORED
2
+ recursive-include c/vendor/sundials *.c *.h
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.4
2
+ Name: mxlpy-native
3
+ Version: 0.4.0
4
+ Summary: Compiled ODE solvers (RADAU5, LSODA, SUNDIALS CVODE) for MxlPy's Native integrator
5
+ Author-email: Marvin van Aalst <marvin.vanaalst@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Computational-Biology-Aachen/mxlpy-native
8
+ Project-URL: Issues, https://github.com/Computational-Biology-Aachen/mxlpy-native/issues
9
+ Classifier: Operating System :: MacOS
10
+ Classifier: Operating System :: Microsoft :: Windows
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: C
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Scientific/Engineering
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: c/vendor/HAIRER-LICENCE.txt
19
+ License-File: c/vendor/SCIPY-LICENCE.txt
20
+ License-File: c/vendor/SUNDIALS-LICENCE.txt
21
+ License-File: c/vendor/SUNDIALS-NOTICE.txt
22
+ Requires-Dist: llvmlite>=0.45
23
+ Dynamic: license-file
24
+
25
+ # mxlpy-native
26
+
27
+ The compiled Radau, LSODA and CVODE solvers behind [MxlPy](https://github.com/Computational-Biology-Aachen/MxlPy)'s `Native` integrator, plus `llvmlite`, which compiles models to machine code for them. Install it through MxlPy rather than on its own:
28
+
29
+ ```bash
30
+ pip install "mxlpy[native]"
31
+ ```
32
+
33
+ ## Solvers and licences
34
+
35
+ | Solver | Origin | Licence |
36
+ |---|---|---|
37
+ | RADAU5 | E. Hairer and G. Wanner, via f2c | `c/vendor/HAIRER-LICENCE.txt` |
38
+ | LSODA | SciPy's C translation of ODEPACK | `c/vendor/SCIPY-LICENCE.txt` |
39
+ | CVODE (BDF and Adams) | [SUNDIALS](https://github.com/LLNL/sundials) v7.9.0, © Lawrence Livermore National Security and the SUNDIALS contributors | `c/vendor/SUNDIALS-LICENCE.txt` (BSD-3-Clause), `c/vendor/SUNDIALS-NOTICE.txt` |
40
+
41
+ All three are vendored from [mxl-solvers](https://github.com/Computational-Biology-Aachen/mxl-solvers), whose README lists the papers to cite for SUNDIALS. The licence files ship in every wheel.
42
+
43
+ ## Platforms
44
+
45
+ Wheels are published for Linux (x86_64, aarch64; glibc 2.28+), macOS (arm64, 12+) and Windows (amd64, arm64), the platforms `llvmlite` has wheels for. On anything else, `mxlpy[native]` installs the WASM backend (`wasmtime`) instead, which runs the same solvers without a compiler, a little slower.
46
+
47
+ If pip has to build from the sdist anyway, it needs a C11 compiler (GCC 8+, Clang 7+ or MSVC 2019 16.8+), and nothing else: no Fortran, BLAS/LAPACK or Python headers. The build says what to install if the compiler is missing or fails.
48
+
49
+ ## Troubleshooting
50
+
51
+ ```bash
52
+ python -m mxlpy_native
53
+ ```
54
+
55
+ prints the installed version, the solver ABI, and whether the compiled solvers and `llvmlite` load, with a fix for each failure.
56
+
57
+ ## Development
58
+
59
+ ```bash
60
+ uv sync # builds the extension in place
61
+ uv run pytest
62
+ ```
63
+
64
+ `c/vendor/` is copied from [mxl-solvers](https://github.com/Computational-Biology-Aachen/mxl-solvers) by its `scripts/vendor.sh`. `vendor/VENDORED` records the commit and file hashes, which `tests/test_vendor.py` checks. Fix solvers there, not here. `c/mxn_solvers.c` is the glue MxlPy calls, compiled unchanged into the wheel and into MxlPy's `solvers.wasm` (`scripts/build_native_wasm.sh` in MxlPy).
65
+
66
+ When an exported function's signature or meaning changes, bump `MXN_ABI_VERSION` in `c/mxn_solvers.c`, `ABI_VERSION` in `src/mxlpy_native/__init__.py` and the ABI MxlPy expects, then release both. MxlPy refuses a mismatched pair with an upgrade hint instead of crashing.
67
+
68
+ ## Releasing
69
+
70
+ Bump `version` in `pyproject.toml` and publish a GitHub release `v<version>`. The release workflow builds the wheels with cibuildwheel plus an sdist and uploads them to PyPI via trusted publishing.
@@ -0,0 +1,46 @@
1
+ # mxlpy-native
2
+
3
+ The compiled Radau, LSODA and CVODE solvers behind [MxlPy](https://github.com/Computational-Biology-Aachen/MxlPy)'s `Native` integrator, plus `llvmlite`, which compiles models to machine code for them. Install it through MxlPy rather than on its own:
4
+
5
+ ```bash
6
+ pip install "mxlpy[native]"
7
+ ```
8
+
9
+ ## Solvers and licences
10
+
11
+ | Solver | Origin | Licence |
12
+ |---|---|---|
13
+ | RADAU5 | E. Hairer and G. Wanner, via f2c | `c/vendor/HAIRER-LICENCE.txt` |
14
+ | LSODA | SciPy's C translation of ODEPACK | `c/vendor/SCIPY-LICENCE.txt` |
15
+ | CVODE (BDF and Adams) | [SUNDIALS](https://github.com/LLNL/sundials) v7.9.0, © Lawrence Livermore National Security and the SUNDIALS contributors | `c/vendor/SUNDIALS-LICENCE.txt` (BSD-3-Clause), `c/vendor/SUNDIALS-NOTICE.txt` |
16
+
17
+ All three are vendored from [mxl-solvers](https://github.com/Computational-Biology-Aachen/mxl-solvers), whose README lists the papers to cite for SUNDIALS. The licence files ship in every wheel.
18
+
19
+ ## Platforms
20
+
21
+ Wheels are published for Linux (x86_64, aarch64; glibc 2.28+), macOS (arm64, 12+) and Windows (amd64, arm64), the platforms `llvmlite` has wheels for. On anything else, `mxlpy[native]` installs the WASM backend (`wasmtime`) instead, which runs the same solvers without a compiler, a little slower.
22
+
23
+ If pip has to build from the sdist anyway, it needs a C11 compiler (GCC 8+, Clang 7+ or MSVC 2019 16.8+), and nothing else: no Fortran, BLAS/LAPACK or Python headers. The build says what to install if the compiler is missing or fails.
24
+
25
+ ## Troubleshooting
26
+
27
+ ```bash
28
+ python -m mxlpy_native
29
+ ```
30
+
31
+ prints the installed version, the solver ABI, and whether the compiled solvers and `llvmlite` load, with a fix for each failure.
32
+
33
+ ## Development
34
+
35
+ ```bash
36
+ uv sync # builds the extension in place
37
+ uv run pytest
38
+ ```
39
+
40
+ `c/vendor/` is copied from [mxl-solvers](https://github.com/Computational-Biology-Aachen/mxl-solvers) by its `scripts/vendor.sh`. `vendor/VENDORED` records the commit and file hashes, which `tests/test_vendor.py` checks. Fix solvers there, not here. `c/mxn_solvers.c` is the glue MxlPy calls, compiled unchanged into the wheel and into MxlPy's `solvers.wasm` (`scripts/build_native_wasm.sh` in MxlPy).
41
+
42
+ When an exported function's signature or meaning changes, bump `MXN_ABI_VERSION` in `c/mxn_solvers.c`, `ABI_VERSION` in `src/mxlpy_native/__init__.py` and the ABI MxlPy expects, then release both. MxlPy refuses a mismatched pair with an upgrade hint instead of crashing.
43
+
44
+ ## Releasing
45
+
46
+ Bump `version` in `pyproject.toml` and publish a GitHub release `v<version>`. The release workflow builds the wheels with cibuildwheel plus an sdist and uploads them to PyPI via trusted publishing.
@@ -1,9 +1,15 @@
1
- /* RADAU5 and LSODA for MxlPy's Native integrator, returning values at requested time
2
- * points. The same source builds the native wheel and solvers.wasm. The solvers
3
- * themselves are vendored from mxl-solvers (see vendor/VENDORED). RADAU5 and this
1
+ /* RADAU5, LSODA and CVODE for MxlPy's Native integrator, returning values at requested
2
+ * time points. The same source builds the native wheel and solvers.wasm. The solvers
3
+ * themselves are vendored from mxl-solvers (see vendor/VENDORED); CVODE is SUNDIALS'
4
+ * (vendor/sundials, BSD-3-Clause, see vendor/SUNDIALS-LICENCE.txt). RADAU5 and this
4
5
  * file keep global state, so only one solve can run at a time in a process. */
5
6
  #include "f2c.h"
6
7
  #include "lsoda.h"
8
+ #include <cvode/cvode.h>
9
+ #include <nvector/nvector_serial.h>
10
+ #include <sunlinsol/sunlinsol_dense.h>
11
+ #include <sunmatrix/sunmatrix_dense.h>
12
+ #include <sunnonlinsol/sunnonlinsol_fixedpoint.h>
7
13
  #include <math.h>
8
14
  #include <stdint.h>
9
15
  #include <stdlib.h>
@@ -15,6 +21,11 @@
15
21
  #define MXN_API
16
22
  #endif
17
23
 
24
+ /* Bump whenever an exported signature or its meaning changes, together with ABI_VERSION
25
+ * in mxlpy_native/__init__.py and the version MxlPy's Native integrator expects. */
26
+ #define MXN_ABI_VERSION 2
27
+ MXN_API int mxn_abi_version(void) { return MXN_ABI_VERSION; }
28
+
18
29
  extern int radau5_(integer *n, U_fp fcn, doublereal *x, doublereal *y, doublereal *xend, doublereal *h,
19
30
  doublereal *rtol, doublereal *atol, integer *itol, U_fp jac, integer *ijac, integer *mljac,
20
31
  integer *mujac, U_fp mas, integer *imas, integer *mlmas, integer *mumas, U_fp solout,
@@ -147,6 +158,75 @@ MXN_API int mxn_lsoda(int n, double *y, double *pars, double rtol, double atol,
147
158
  return 2;
148
159
  }
149
160
 
161
+ static int cvode_rhs(sunrealtype t, N_Vector y, N_Vector dydt, void *user_data) {
162
+ (void)user_data;
163
+ int n = (int)N_VGetLength(y);
164
+ double *f = N_VGetArrayPointer(dydt);
165
+ g_model(n, t, N_VGetArrayPointer(y), f, g_pars);
166
+ for (int i = 0; i < n; i++) {
167
+ if (!isfinite(f[i])) return 1; /* recoverable: CVODE retries with a smaller step */
168
+ }
169
+ return 0;
170
+ }
171
+
172
+ /* Same contract as mxn_lsoda, with SUNDIALS' CVODE: BDF with Newton iteration and a dense
173
+ * difference-quotient Jacobian, or with adams != 0, Adams-Moulton with fixed-point
174
+ * iteration. nmax caps the total number of steps. Returns 1 on success, or CVODE's
175
+ * negative flag: -1 too many steps, -2 too much accuracy requested, -3 repeated error
176
+ * test failures, -4 repeated convergence failures, -8 the right-hand side kept failing
177
+ * (non-finite), -22 bad input, ... (see cvode.h). Returns -99 if allocation fails or the
178
+ * result isn't finite. */
179
+ MXN_API int mxn_cvode(int n, double *y, double *pars, double rtol, double atol, int nmax, int adams, int n_out,
180
+ const double *t_out, double *y_out) {
181
+ SUNContext ctx = NULL;
182
+ if (SUNContext_Create(SUN_COMM_NULL, &ctx) != 0) return -99;
183
+ N_Vector v = N_VMake_Serial(n, y, ctx); /* works on y in place */
184
+ void *mem = CVodeCreate(adams ? CV_ADAMS : CV_BDF, ctx);
185
+ SUNMatrix A = NULL;
186
+ SUNLinearSolver ls = NULL;
187
+ SUNNonlinearSolver nls = NULL;
188
+ int flag = (v && mem) ? CV_SUCCESS : -99;
189
+ g_pars = pars;
190
+ if (flag == CV_SUCCESS) flag = CVodeInit(mem, cvode_rhs, t_out[0], v);
191
+ if (flag == CV_SUCCESS) flag = CVodeSStolerances(mem, rtol, atol);
192
+ /* Never step past the last output time: models needn't be defined beyond it. */
193
+ if (flag == CV_SUCCESS) flag = CVodeSetStopTime(mem, t_out[n_out - 1]);
194
+ if (flag == CV_SUCCESS && adams) {
195
+ nls = SUNNonlinSol_FixedPoint(v, 0, ctx);
196
+ flag = nls ? CVodeSetNonlinearSolver(mem, nls) : -99;
197
+ } else if (flag == CV_SUCCESS) {
198
+ A = SUNDenseMatrix(n, n, ctx);
199
+ ls = A ? SUNLinSol_Dense(v, A, ctx) : NULL;
200
+ flag = ls ? CVodeSetLinearSolver(mem, ls, A) : -99;
201
+ }
202
+ memcpy(y_out, y, (size_t)n * sizeof(double));
203
+ double t = t_out[0];
204
+ for (int k = 1; k < n_out && flag >= 0; k++) {
205
+ if (t_out[k] != t_out[k - 1]) {
206
+ long int steps = 0;
207
+ CVodeGetNumSteps(mem, &steps);
208
+ if (steps >= nmax) {
209
+ flag = CV_TOO_MUCH_WORK;
210
+ break;
211
+ }
212
+ CVodeSetMaxNumSteps(mem, nmax - steps);
213
+ flag = CVode(mem, t_out[k], v, &t, CV_NORMAL);
214
+ }
215
+ if (flag >= 0) memcpy(y_out + (size_t)k * (size_t)n, y, (size_t)n * sizeof(double));
216
+ }
217
+ CVodeFree(&mem);
218
+ SUNNonlinSolFree(nls);
219
+ SUNLinSolFree(ls);
220
+ SUNMatDestroy(A);
221
+ N_VDestroy(v);
222
+ SUNContext_Free(&ctx);
223
+ if (flag < 0) return flag;
224
+ for (int i = 0; i < n; i++) {
225
+ if (!isfinite(y[i])) return -99;
226
+ }
227
+ return 1;
228
+ }
229
+
150
230
  /* Evaluates fn once per row of y, writing n_out values per row into out. */
151
231
  MXN_API void mxn_eval_rows(intptr_t fn, int n, int n_out, int rows, const double *t, double *y, double *out,
152
232
  double *pars) {
@@ -0,0 +1,31 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025-2026, Lawrence Livermore National Security, University of Maryland Baltimore County, and the SUNDIALS contributors.
4
+ Copyright (c) 2013-2025, Lawrence Livermore National Security and Southern Methodist University.
5
+ Copyright (c) 2002-2013, Lawrence Livermore National Security.
6
+ All rights reserved.
7
+
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions are met:
10
+
11
+ * Redistributions of source code must retain the above copyright notice, this
12
+ list of conditions and the following disclaimer.
13
+
14
+ * Redistributions in binary form must reproduce the above copyright notice,
15
+ this list of conditions and the following disclaimer in the documentation
16
+ and/or other materials provided with the distribution.
17
+
18
+ * Neither the name of the copyright holder nor the names of its
19
+ contributors may be used to endorse or promote products derived from
20
+ this software without specific prior written permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,21 @@
1
+ This work was produced under the auspices of the U.S. Department of
2
+ Energy by Lawrence Livermore National Laboratory under Contract
3
+ DE-AC52-07NA27344.
4
+
5
+ This work was prepared as an account of work sponsored by an agency of
6
+ the United States Government. Neither the United States Government nor
7
+ Lawrence Livermore National Security, LLC, nor any of their employees
8
+ makes any warranty, expressed or implied, or assumes any legal liability
9
+ or responsibility for the accuracy, completeness, or usefulness of any
10
+ information, apparatus, product, or process disclosed, or represents that
11
+ its use would not infringe privately owned rights.
12
+
13
+ Reference herein to any specific commercial product, process, or service
14
+ by trade name, trademark, manufacturer, or otherwise does not necessarily
15
+ constitute or imply its endorsement, recommendation, or favoring by the
16
+ United States Government or Lawrence Livermore National Security, LLC.
17
+
18
+ The views and opinions of authors expressed herein do not necessarily
19
+ state or reflect those of the United States Government or Lawrence
20
+ Livermore National Security, LLC, and shall not be used for advertising
21
+ or product endorsement purposes.
@@ -0,0 +1,92 @@
1
+ # Vendored from https://github.com/Computational-Biology-Aachen/mxl-solvers at 6f3cc88e60510bae954d20e97fe4435bba3c6a1c.
2
+ # Don't edit these files here: change mxl-solvers, then re-run its scripts/vendor.sh.
3
+ da5d9b896c422aa002b6d8fc3c7003a6e6345454afd700ae65fa3cd944ab12e5 radau5.c
4
+ 8d2173c6ae898e77a71c2dc52e027ce2b6185d91170bd5f031b185aff6e1d354 dc_decsol.c
5
+ 9dc2c0ede63b1511813fbde4300c23a6c1e0536e4d316c6fd5492ae0f20d8195 decsol.c
6
+ cf5d31866e63553809a79416b6baa957be45e3c03a5da59254fbbb317c735cfc f2c.h
7
+ 5ab404a0cbf7e02c21105b9f8322cb65ef78e10f40937740a9cc90b36796b8b8 libf2c_stubs.c
8
+ 2f05643511057c06ceed0d8a1d7181857f93a759a60139d7506a4b6123654ac7 lsoda.c
9
+ 751d5aa397f303b491d78f689dbf5b779f32b2d158b58c2b861d58143702e1f9 lsoda.h
10
+ 8076d5b1bd27484ce6214cc5f9df7d6c88225182498538c9a878ed14d1743836 blaslapack_declarations.h
11
+ c615cf28e6d41f150f631d0b7fa73f6b2d8b694a88818a38851f54b0efec042c mxs_lapack.c
12
+ 0e9a5c3ba2637f05909967c3eeeac9c7b9a4a4c6e92801a408afd2aa725024e2 sundials/include/cvode/cvode.h
13
+ adb1e5836989c630b595b14c0fa213426ddbfd3a87d14b581a470d5272b5881b sundials/include/cvode/cvode_diag.h
14
+ 84dfab497850c933b8020cc0b2236a2e85bfe5fceffe4b5aefc8a1b518dd68a3 sundials/include/cvode/cvode_ls.h
15
+ 86a439a57e9fbc1990a3167592a5417806b3f0c11a33e0008ce907386ffe4634 sundials/include/cvode/cvode_proj.h
16
+ 1d506e67d5db4438b6ef0d814c22efc99edde53ef4b37ea507d12bef2c08001f sundials/include/nvector/nvector_serial.h
17
+ 79ed44b5c1236088bcc878e1de5084664dc4a1b3ee153094b5da81f263906fc6 sundials/include/sundials/priv/sundials_context_impl.h
18
+ f534d085757203cfea2da292fdc631076b96fc73dc12bb0a96d8a3b186828af4 sundials/include/sundials/priv/sundials_errors_impl.h
19
+ 7d19b2c96f357b7f4f3a815a8f51f317af8ad87bfd4e79e87e94d37ac134a69d sundials/include/sundials/priv/sundials_logger_macros.h
20
+ bf5493735899a4cc63162d64a2f374474efe7febf556b2477f6799ee2560d759 sundials/include/sundials/sundials_adaptcontroller.h
21
+ 4db307e54511800c8c1a0418ffaa85c81f1f73a6c98d10d510d1aa57686f45f0 sundials/include/sundials/sundials_adjointcheckpointscheme.h
22
+ 37bca6199a4fa9a4f7639ff72af47284c44277b437b5074cc26b50765d4f4d6c sundials/include/sundials/sundials_adjointstepper.h
23
+ ed847fda53456b56ad2cf3523371281b510687739a6d2246285f78cf2ac24cb6 sundials/include/sundials/sundials_band.h
24
+ c191637b3470b5cf068cc527c0de5966364cdcbb9a4df7418a1cfee619906e0d sundials/include/sundials/sundials_config.h
25
+ 20d24a8a49fa27f45d2e9f3fe89269096b5b80d9fc0c924eb3592fe6e16d6f10 sundials/include/sundials/sundials_context.h
26
+ b57c39d153ba0d23b26401bcdeac3fe0f123a5ee756652bb844b57d567ca4c65 sundials/include/sundials/sundials_core.h
27
+ 3779aab4236405ffeb3df4bb91dd2c7c640d691bf67753d97f8487c17aa1775d sundials/include/sundials/sundials_dense.h
28
+ 080a893fcf9ba48008172ac2b27e6a5a6dd07a747c3512aefb3ede3f6d0af389 sundials/include/sundials/sundials_direct.h
29
+ d31cbeb674e221925e7028ef4b40270075a5685d2f1708d90629090e863cdbb6 sundials/include/sundials/sundials_domeigestimator.h
30
+ 2b7f3d812009bbc19ec47c21e2eec18a36f0b76efa55dda9c0cd331fa4559e38 sundials/include/sundials/sundials_errors.h
31
+ 51a9fb7365677b78dbf3ff7f5737500d309217f1ea3308a6b7098866d6d56fca sundials/include/sundials/sundials_export.h
32
+ da1f5c38312951c2b8f3c5d8101eda2b37a8390032d85144b948aa424632df6b sundials/include/sundials/sundials_futils.h
33
+ 9497398cc6e5b41e304374e9799efe81cd8de6e0691f96b6f7ef39c98f19e1d1 sundials/include/sundials/sundials_iterative.h
34
+ 5014b4ac0e5ba295215cda7a8df979a87d5d9e19ee8d9d124f203091d7127fbf sundials/include/sundials/sundials_linearsolver.h
35
+ 253a57a0f38229057c50418358788549739eed3fe465f85e179ce56a5ea6fdbc sundials/include/sundials/sundials_logger.h
36
+ 4f1d6030e6c942bf5b8af93f82184b8931549ab60b8a16301afc7b2e98e52d20 sundials/include/sundials/sundials_math.h
37
+ 3921cfbd55c674f56dbdd3d138cdf42df8724fbf6cdcc8dd707f03608966dd86 sundials/include/sundials/sundials_matrix.h
38
+ 03d73b7660b6eaeb11c30ac3abc0bf9d347199f68d699e9cd47a29eb54bdc655 sundials/include/sundials/sundials_memory.h
39
+ 0bb0f46e0430df2a43ec92a522d8a43aeb602edae9295bbbb0e78e3156d67bbb sundials/include/sundials/sundials_nonlinearsolver.h
40
+ ce10747b53a8e63e4e9db4dcb9d6f6c6b3ff042d8b8e8497f0e69726c851193a sundials/include/sundials/sundials_nvector.h
41
+ 5b8ae9158c438f5272bd475514389c5793023a1d18021e8bd8da9f1952b6f08e sundials/include/sundials/sundials_nvector_senswrapper.h
42
+ 430352c17759d4719c4e8348849eb6750b7ef3dcdef63e5c3964aa076e515269 sundials/include/sundials/sundials_profiler.h
43
+ e9b443699bf8a01366eb7e21e9f009c4b1510d6144626afc94a31ade35d154ec sundials/include/sundials/sundials_stepper.h
44
+ e0fc8e9fc04ef756f6d148a70a0b223c2fdb769a6cc67b31c3a3f0091492fff6 sundials/include/sundials/sundials_types.h
45
+ 203a1833d06ca499575fb8038f58e98e6f5585e0fad6f3d15c910af80b345fcd sundials/include/sundials/sundials_version.h
46
+ 018f2430dd2965a9184b20822adcd4518099278f89c367ffe1f59a6db6e5e78a sundials/include/sunlinsol/sunlinsol_dense.h
47
+ 6f096a67d7609c6617d6ec9eed79da95b0ede921a9fe631301149c0c241eba0e sundials/include/sunmatrix/sunmatrix_band.h
48
+ b1835f8bd9eecc879653d78782602123ca62b12fad1861f4c1973cadae2ec492 sundials/include/sunmatrix/sunmatrix_dense.h
49
+ 76306ea569f779f18a1a79f82a27e6422db37e9bee0953099e65ec73095d109d sundials/include/sunmatrix/sunmatrix_sparse.h
50
+ 18afbd9ff9fd2a3ba9bbaecbb029250ec462571fa52f5562fa4f90255eba68af sundials/include/sunnonlinsol/sunnonlinsol_fixedpoint.h
51
+ ed507a3bb80066f07a267fdfe6e1af050b75dc896202585be69dcf8c8426761f sundials/include/sunnonlinsol/sunnonlinsol_newton.h
52
+ 7590f4ec73215229be22479b3af8856395232191985eff364e30709aebe2322a sundials/src/cvode/cvode.c
53
+ 8a803cbdd874d462e4f8f1bebacea3e5aebed7b8cdc02dd94eaddc8637dcdee4 sundials/src/cvode/cvode_diag_impl.h
54
+ 33781c0673da6318a75b8577fe6d9f98800c6adcfff497ceeb15c9d8f95ef2d7 sundials/src/cvode/cvode_fused_stubs.c
55
+ d22ef38c930b247dfaefc1d921ad3444f629a521998f0697c0227b29841da87d sundials/src/cvode/cvode_impl.h
56
+ e8fbe1785079b69f42c8d8c449c800512ab3a31f3c79f3226c7580283788b789 sundials/src/cvode/cvode_io.c
57
+ 31b16188b4257930832aeb5a4984d4fcebcb050c30cadf01603d63eb1ce07240 sundials/src/cvode/cvode_ls.c
58
+ 1c151437138df09b3b3f6d36be2453f068bfc5e04c05cc757152d85a0ff9a026 sundials/src/cvode/cvode_ls_impl.h
59
+ 2cbe80dfeb66adf0a10fae045ac8a1f44d161e50afe36a10de9765cfbd57b07d sundials/src/cvode/cvode_nls.c
60
+ 2e1d255c02d8c18fd7f9f6e56070fcd199acf3ed233e485c9767c0a574ffe0f5 sundials/src/cvode/cvode_proj.c
61
+ 084e96897f8188dbf5f8dd793865bc9a01884879f9b5e79cbfc7d75eeb7539cc sundials/src/cvode/cvode_proj_impl.h
62
+ 73bbdef0bc605a2afd9aded688ae421f7b8deb285bfa4122040182e26c4615d9 sundials/src/nvector/serial/nvector_serial.c
63
+ d88e0e15aa60f7ac7379d15c869fa1a2f38d732afed89a9a448bf7a564a7a606 sundials/src/sundials/stl/sunstl_vector.h
64
+ 2fb830b870a1d53f7f26355f20737b74e4124aaa6cb96a03137cffd84a20dc58 sundials/src/sundials/sundials_adiak_metadata.h
65
+ 654e4100b6c9a41d7a4d69f3dfc9f858ffdeb9fb031119308555dbb625877e69 sundials/src/sundials/sundials_band.c
66
+ a753c7b3b862bf6f68ad7d47a6bfbf3ecd41feca645c2bca79f9d8eea646361a sundials/src/sundials/sundials_context.c
67
+ f8fcf707e6d875ed4c52c804374f5f31bc320d0060e20b1bfacbf768c9475ce5 sundials/src/sundials/sundials_debug.h
68
+ da668d7469df705811a49a5b50b24c8a8969abcd3894f554a301b7a58f8add06 sundials/src/sundials/sundials_dense.c
69
+ 055a45d2156d36fe3976f9e1b8e53c4a22b8f5a74cd676c9cd301cef264f09d7 sundials/src/sundials/sundials_errors.c
70
+ beff39ff5ba7ec06613dea70833438fc98fb9f307473d6879fe004b54d9b88b2 sundials/src/sundials/sundials_futils.c
71
+ 1e214df5bae719d5f22824484ba8324862295d9c3f773e187f38d1401b2ad5dd sundials/src/sundials/sundials_hashmap_impl.h
72
+ e3c74781f6faddcb3bca67cf7099aabba9d765fb6bd5880cc7f66adb0a931c9b sundials/src/sundials/sundials_linearsolver.c
73
+ 580f6282419efdd3045af571eb17f75a15945ccb675fbc2bbf5e58481a8a3148 sundials/src/sundials/sundials_logger.c
74
+ a9297d70aaf8f32d96fb2a7eb5cba252d2a11434c5bf066bd089fd68761a3d16 sundials/src/sundials/sundials_logger_impl.h
75
+ a0aec9a25ea7ad2800b3ed8a079e4e0136179d693ee68d1beb5c5a001f5c4cba sundials/src/sundials/sundials_macros.h
76
+ 73e9429f1f9efe7d3d59ba44b7e26b06f35b16d41b83bb04bd7a77a37cec2d26 sundials/src/sundials/sundials_math.c
77
+ be7d93993852c61dce7466b4849b2767400d10eaa174446482a20312f07c5f92 sundials/src/sundials/sundials_matrix.c
78
+ 8bc7bdbcaaa5a96cb1de49ed21b9c2f83dd03f4e1f13308291171531f67d9d39 sundials/src/sundials/sundials_memory.c
79
+ e35bff8b6463a8300aa01053c21e2e0438bc63d23db55dfa28dcf4840db89c3a sundials/src/sundials/sundials_nonlinearsolver.c
80
+ 289de7fa60d16e359f739a2905f854d138bead78d8d2fd5f234d8c8034f2fff5 sundials/src/sundials/sundials_nvector.c
81
+ bba2bb148b239b3abfdc46f165cd01dea656feb4bb4f6492d3155e598ce49639 sundials/src/sundials/sundials_nvector_senswrapper.c
82
+ b7c5bfbdde79abf9f9b37312d1a565799714e264d49a425ff9e843e9f644d448 sundials/src/sundials/sundials_utils.h
83
+ d8eb26aee21f2d370689e722eff9f65f5e6f71e23142fefafdb8ea2657657c6d sundials/src/sundials/sundials_version.c
84
+ 3213ea349f4e64543dd66b3f20bfc7454481eabf7ad6f3ddb1d5505aeac3d10f sundials/src/sunlinsol/dense/sunlinsol_dense.c
85
+ 280a4e54da0e3732fac6911f96d8a87c97e1183d5627338b6dd0ef46504af25f sundials/src/sunmatrix/band/sunmatrix_band.c
86
+ 7418295ae120d40f3a139421c21b01e1fcbca74d8e717dc41088c7e9a854bcf2 sundials/src/sunmatrix/dense/sunmatrix_dense.c
87
+ acc17ac1685b3ef154387b62ec8fe8f2b93d634c820d59d04b6d044f5c73bd66 sundials/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c
88
+ 6d642aea374abac22c30e718b75700aaa20e9aec818a76912ba5fdb48e8d8be6 sundials/src/sunnonlinsol/newton/sunnonlinsol_newton.c
89
+ 49bcfad0e3bbe5c3a0428624254567f32786948332a3204fc1e35b8b2a02b0fd HAIRER-LICENCE.txt
90
+ 221e59f5e910fd7f94e44f0dac77436a11338c285c6346232e4a850a50da0e94 SCIPY-LICENCE.txt
91
+ d83f244e1bef3d00a88d043d37d9cd2493c7aa19c9fbf35a837b310e867897a6 SUNDIALS-LICENCE.txt
92
+ 5cb9c6b0ca7c09b26fe2d1f9ef45231086c9ea2cdb32eb5f9dce7012e2364bc2 SUNDIALS-NOTICE.txt