numeric-al 2026.10.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 René Chenard
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.
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: numeric-al
3
+ Version: 2026.10.0
4
+ Summary: NumericAL — a generic, header-only numerical library: tensors and Einstein summation
5
+ Author-email: René Chenard <rene.chenard.1@ulaval.ca>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/RECHE23/NumericAL
8
+ Project-URL: Issues, https://github.com/RECHE23/NumericAL/issues
9
+ Keywords: tensor,einsum,linear-algebra,numerical,dlpack,array-interface
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: C++
16
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # NumericAL
25
+
26
+ A pure, header-only C++20 **numerical computing** library — a leaf of the
27
+ SciLang ecosystem (a sibling of [REAL](https://github.com/RECHE23/real-regex)),
28
+ generic over its scalar type and depending on nothing but the C++ standard
29
+ library.
30
+
31
+ NumericAL is **agnostic of expressions and of any symbolic layer**: it computes
32
+ with concrete numeric structures — vectors, matrices, tensors — and the
33
+ algorithms over them. SciLang consumes it as a numeric backend through its
34
+ module seam; the symbolic↔numeric reconciliation stays in SciLang.
35
+
36
+ ## Capabilities
37
+
38
+ Small and complete, grown measured, honest about what is not yet here:
39
+
40
+ - `numerical::vector<T>` — a dense, value-semantic vector: element-wise arithmetic,
41
+ scalar multiplication, dot product, tolerance comparison, shape checks.
42
+ - `numerical::matrix<T>` — a dense, row-major, value-semantic matrix: element-wise
43
+ arithmetic, scalar / matrix–vector / matrix–matrix products, transpose,
44
+ tolerance comparison, shape checks.
45
+ - `numerical::lu_decomposition<T>` — an LU factorisation (partial pivoting) computed
46
+ once and reused: `solve` (any number of right-hand sides), `determinant`, and
47
+ `inverse`. Free `solve` / `determinant` / `inverse` are one-shot conveniences.
48
+ - `numerical::cholesky_decomposition<T>` — `A = L Lᴴ` for a Hermitian
49
+ positive-definite matrix (about twice as cheap as LU): the factor `lower()`,
50
+ `solve`, and `determinant`; throws `not_positive_definite_error` otherwise.
51
+ - `numerical::qr_decomposition<T>` — `A = Q R` (modified Gram–Schmidt) for an
52
+ `m × n` matrix with `m ≥ n`: the factors `q()` / `r()` and a least-squares
53
+ `solve` of `A x ≈ b`; throws `singular_matrix_error` if the columns are dependent.
54
+ - `numerical::symmetric_eigen` — eigenvalues (ascending) and eigenvectors of a real
55
+ symmetric matrix by cyclic Jacobi rotations (`A = V Λ Vᵀ`).
56
+ - `numerical::svd_decomposition` — the singular value decomposition `A = U Σ Vᵀ`
57
+ of a real `m × n` matrix (`m ≥ n`), via the eigendecomposition of `Aᵀ A`:
58
+ `singular_values()` (descending), `u()`, `v()`.
59
+ - `numerical::tensor<T>` — a dense, row-major, N-dimensional tensor (rank-1 is a
60
+ vector, rank-2 a matrix, rank-0 a scalar; built directly or from a `vector` /
61
+ `matrix`), with **`einsum`** — Einstein-summation index notation for
62
+ contractions and general products, as in NumPy / PyTorch. `einsum` is the
63
+ unifying primitive of the algebra: `"ij,jk->ik"` is the matrix product,
64
+ `"i,i->"` the dot product, `"ij->ji"` the transpose, `"ii->"` the trace,
65
+ `"i,j->ij"` the outer product, `"ij->i"` a row reduction. It takes one or more
66
+ operands and sums over every label absent from the output, in a deterministic
67
+ order.
68
+
69
+ **Grows in as measured:** sparse storage, complex
70
+ Hermitian eigen/SVD, non-symmetric eigenvalues, FFT, numeric autodiff, iterative
71
+ solvers, numerical integration, arbitrary precision.
72
+
73
+ ## Build
74
+
75
+ ```bash
76
+ make test # build and run the test suite
77
+ make coverage # line-coverage summary + HTML report
78
+ make sanitize # tests under AddressSanitizer + UndefinedBehaviorSanitizer
79
+ make lint # clang-tidy
80
+ make format # uncrustify, in place
81
+ make doc # API reference (Doxygen) with embedded coverage
82
+ ```
83
+
84
+ Override the compiler with `make test CXX=g++-14`.
85
+
86
+ `numerical::numerical` is the CMake target — `add_subdirectory`, `FetchContent`, or an
87
+ installed config package:
88
+
89
+ ```cmake
90
+ # After `cmake --install <build> --prefix <prefix>`:
91
+ find_package(numerical CONFIG REQUIRED)
92
+ target_link_libraries(app PRIVATE numerical::numerical)
93
+ ```
94
+
95
+ ## Releasing
96
+
97
+ `make release` computes the next calendar version `YYYY.M.PATCH` — the patch
98
+ resets each month, the first release of a month is `.0` (PEP 440 drops leading
99
+ zeros, so `2026.6.1`, never `2026.06.001`) — bumps it in `pyproject.toml` and
100
+ `python/numerical/__init__.py`, then commits, tags and pushes from a clean `main`.
101
+ Pushing the tag drives `release.yml`, which checks the tag matches the version,
102
+ builds the abi3 wheels (Linux x86-64/aarch64, macOS universal, Windows) and the
103
+ sdist, and publishes to PyPI via Trusted Publishing (OIDC, no stored secret).
104
+
105
+ One-time PyPI setup (before the first release): create a
106
+ [Trusted Publisher](https://docs.pypi.org/trusted-publishers/) for the project
107
+ `numeric-al` — owner `RECHE23`, repository `NumericAL`, workflow `release.yml`,
108
+ environment `pypi` — and create the matching GitHub Environment named `pypi`.
109
+ Until that exists the build/sdist jobs still run, but the publish step fails;
110
+ the pushed tag remains a valid versioned snapshot regardless.
111
+
112
+ ## Python binding
113
+
114
+ ```sh
115
+ pip install numeric-al # the distribution is numeric-al; the module is numerical
116
+ ```
117
+
118
+ A CPython binding (stable ABI, one `cp310` abi3 wheel serves 3.10+) exposes the
119
+ unifying object `numerical.Tensor` (rank-1 a vector, rank-2 a matrix, rank-0 a
120
+ scalar; `float64` or `complex128`) and the algebra over it:
121
+
122
+ ```python
123
+ import numerical
124
+ a = numerical.Tensor([1, 2, 3, 4], shape=(2, 2))
125
+ b = numerical.Tensor([5, 6, 7, 8], shape=(2, 2))
126
+ numerical.einsum("ij,jk->ik", a, b) # matrix product
127
+ numerical.einsum("i,i->", numerical.Tensor([1, 2, 3]), numerical.Tensor([1, 2, 3])) # dot
128
+ numerical.solve(a, numerical.Tensor([1.0, 1.0])) # a @ x = b
129
+ ```
130
+
131
+ The decomposition layer is exposed too (a `numpy.linalg`-style surface):
132
+ `determinant(a)`, `inverse(a)`, `lstsq(a, b)`, `cholesky(a)`, `qr(a)` → `(Q, R)`,
133
+ `eigh(a)` → `(values, vectors)`, `svd(a)` → `(U, S, V)`. `determinant` / `inverse`
134
+ / `lstsq` / `cholesky` / `qr` accept `float64` and `complex128`; `eigh` / `svd`
135
+ are `float64` only (matching the C++ layer).
136
+
137
+ A `Tensor` is a citizen of the scientific Python stack, **zero-copy**:
138
+
139
+ ```python
140
+ import numpy as np, torch
141
+ np.asarray(t) # via __array_interface__ (a read-only view)
142
+ np.from_dlpack(t) # via __dlpack__
143
+ torch.from_dlpack(t) # the same DLPack capsule — JAX / CuPy consume it too
144
+ numerical.asarray(np.eye(3)) # the other direction (a contiguous-array copy)
145
+ ```
146
+
147
+ `numerical.get_include()` returns the header directory, so the C++ library can be
148
+ located through its Python install. `make python` builds the extension in place;
149
+ `make python-test` runs the binding suite — including a seeded **differential
150
+ fuzzer** that checks hundreds of random einsum specifications and linear-algebra
151
+ problems against NumPy within tolerance (when NumPy is importable, as in CI). PETSc (petsc4py) has no such exchange protocol — bridging it
152
+ would require an explicit copy into a PETSc object.
153
+
154
+ ## Benchmarks
155
+
156
+ NumericAL is validated against **NumPy** for both result and speed — `make
157
+ bench-python` checks every operation matches NumPy within a tolerance, then times
158
+ it; `make python-test` runs the correctness parity suite alone (also in CI). The
159
+ results and methodology, with an honest reading of the gap, are in
160
+ [BENCHMARKS.md](BENCHMARKS.md): NumericAL is a portable, dependency-free reference
161
+ implementation: correct within tolerance, and competitive with NumPy's own
162
+ `einsum`/`linalg` (it beats `np.einsum`'s non-BLAS path and the decompositions
163
+ land within ~1–4×). Against hand-tuned BLAS (`np.matmul`) its cache-blocked,
164
+ `std::thread`-parallel GEMM is ~10× slower but steady (no cache cliff) — that gap
165
+ is BLAS's per-architecture SIMD micro-kernel, which a header-only library does not
166
+ chase. See [BENCHMARKS.md](BENCHMARKS.md) for the honest details.
167
+
168
+ ## Numerical discipline
169
+
170
+ Floating-point accuracy is documented, never claimed exact where it cannot be;
171
+ results are deterministic given inputs and any tolerance/seed; differential
172
+ tests compare against references **within a documented tolerance**. Same gate
173
+ bar as the rest of the ecosystem: 100% coverage, clang **and** g++-14, lint,
174
+ format, and sanitizers green.
175
+
176
+ ## License
177
+
178
+ MIT — see [LICENSE](LICENSE).
179
+
180
+ ## Author
181
+
182
+ René Chenard
@@ -0,0 +1,159 @@
1
+ # NumericAL
2
+
3
+ A pure, header-only C++20 **numerical computing** library — a leaf of the
4
+ SciLang ecosystem (a sibling of [REAL](https://github.com/RECHE23/real-regex)),
5
+ generic over its scalar type and depending on nothing but the C++ standard
6
+ library.
7
+
8
+ NumericAL is **agnostic of expressions and of any symbolic layer**: it computes
9
+ with concrete numeric structures — vectors, matrices, tensors — and the
10
+ algorithms over them. SciLang consumes it as a numeric backend through its
11
+ module seam; the symbolic↔numeric reconciliation stays in SciLang.
12
+
13
+ ## Capabilities
14
+
15
+ Small and complete, grown measured, honest about what is not yet here:
16
+
17
+ - `numerical::vector<T>` — a dense, value-semantic vector: element-wise arithmetic,
18
+ scalar multiplication, dot product, tolerance comparison, shape checks.
19
+ - `numerical::matrix<T>` — a dense, row-major, value-semantic matrix: element-wise
20
+ arithmetic, scalar / matrix–vector / matrix–matrix products, transpose,
21
+ tolerance comparison, shape checks.
22
+ - `numerical::lu_decomposition<T>` — an LU factorisation (partial pivoting) computed
23
+ once and reused: `solve` (any number of right-hand sides), `determinant`, and
24
+ `inverse`. Free `solve` / `determinant` / `inverse` are one-shot conveniences.
25
+ - `numerical::cholesky_decomposition<T>` — `A = L Lᴴ` for a Hermitian
26
+ positive-definite matrix (about twice as cheap as LU): the factor `lower()`,
27
+ `solve`, and `determinant`; throws `not_positive_definite_error` otherwise.
28
+ - `numerical::qr_decomposition<T>` — `A = Q R` (modified Gram–Schmidt) for an
29
+ `m × n` matrix with `m ≥ n`: the factors `q()` / `r()` and a least-squares
30
+ `solve` of `A x ≈ b`; throws `singular_matrix_error` if the columns are dependent.
31
+ - `numerical::symmetric_eigen` — eigenvalues (ascending) and eigenvectors of a real
32
+ symmetric matrix by cyclic Jacobi rotations (`A = V Λ Vᵀ`).
33
+ - `numerical::svd_decomposition` — the singular value decomposition `A = U Σ Vᵀ`
34
+ of a real `m × n` matrix (`m ≥ n`), via the eigendecomposition of `Aᵀ A`:
35
+ `singular_values()` (descending), `u()`, `v()`.
36
+ - `numerical::tensor<T>` — a dense, row-major, N-dimensional tensor (rank-1 is a
37
+ vector, rank-2 a matrix, rank-0 a scalar; built directly or from a `vector` /
38
+ `matrix`), with **`einsum`** — Einstein-summation index notation for
39
+ contractions and general products, as in NumPy / PyTorch. `einsum` is the
40
+ unifying primitive of the algebra: `"ij,jk->ik"` is the matrix product,
41
+ `"i,i->"` the dot product, `"ij->ji"` the transpose, `"ii->"` the trace,
42
+ `"i,j->ij"` the outer product, `"ij->i"` a row reduction. It takes one or more
43
+ operands and sums over every label absent from the output, in a deterministic
44
+ order.
45
+
46
+ **Grows in as measured:** sparse storage, complex
47
+ Hermitian eigen/SVD, non-symmetric eigenvalues, FFT, numeric autodiff, iterative
48
+ solvers, numerical integration, arbitrary precision.
49
+
50
+ ## Build
51
+
52
+ ```bash
53
+ make test # build and run the test suite
54
+ make coverage # line-coverage summary + HTML report
55
+ make sanitize # tests under AddressSanitizer + UndefinedBehaviorSanitizer
56
+ make lint # clang-tidy
57
+ make format # uncrustify, in place
58
+ make doc # API reference (Doxygen) with embedded coverage
59
+ ```
60
+
61
+ Override the compiler with `make test CXX=g++-14`.
62
+
63
+ `numerical::numerical` is the CMake target — `add_subdirectory`, `FetchContent`, or an
64
+ installed config package:
65
+
66
+ ```cmake
67
+ # After `cmake --install <build> --prefix <prefix>`:
68
+ find_package(numerical CONFIG REQUIRED)
69
+ target_link_libraries(app PRIVATE numerical::numerical)
70
+ ```
71
+
72
+ ## Releasing
73
+
74
+ `make release` computes the next calendar version `YYYY.M.PATCH` — the patch
75
+ resets each month, the first release of a month is `.0` (PEP 440 drops leading
76
+ zeros, so `2026.6.1`, never `2026.06.001`) — bumps it in `pyproject.toml` and
77
+ `python/numerical/__init__.py`, then commits, tags and pushes from a clean `main`.
78
+ Pushing the tag drives `release.yml`, which checks the tag matches the version,
79
+ builds the abi3 wheels (Linux x86-64/aarch64, macOS universal, Windows) and the
80
+ sdist, and publishes to PyPI via Trusted Publishing (OIDC, no stored secret).
81
+
82
+ One-time PyPI setup (before the first release): create a
83
+ [Trusted Publisher](https://docs.pypi.org/trusted-publishers/) for the project
84
+ `numeric-al` — owner `RECHE23`, repository `NumericAL`, workflow `release.yml`,
85
+ environment `pypi` — and create the matching GitHub Environment named `pypi`.
86
+ Until that exists the build/sdist jobs still run, but the publish step fails;
87
+ the pushed tag remains a valid versioned snapshot regardless.
88
+
89
+ ## Python binding
90
+
91
+ ```sh
92
+ pip install numeric-al # the distribution is numeric-al; the module is numerical
93
+ ```
94
+
95
+ A CPython binding (stable ABI, one `cp310` abi3 wheel serves 3.10+) exposes the
96
+ unifying object `numerical.Tensor` (rank-1 a vector, rank-2 a matrix, rank-0 a
97
+ scalar; `float64` or `complex128`) and the algebra over it:
98
+
99
+ ```python
100
+ import numerical
101
+ a = numerical.Tensor([1, 2, 3, 4], shape=(2, 2))
102
+ b = numerical.Tensor([5, 6, 7, 8], shape=(2, 2))
103
+ numerical.einsum("ij,jk->ik", a, b) # matrix product
104
+ numerical.einsum("i,i->", numerical.Tensor([1, 2, 3]), numerical.Tensor([1, 2, 3])) # dot
105
+ numerical.solve(a, numerical.Tensor([1.0, 1.0])) # a @ x = b
106
+ ```
107
+
108
+ The decomposition layer is exposed too (a `numpy.linalg`-style surface):
109
+ `determinant(a)`, `inverse(a)`, `lstsq(a, b)`, `cholesky(a)`, `qr(a)` → `(Q, R)`,
110
+ `eigh(a)` → `(values, vectors)`, `svd(a)` → `(U, S, V)`. `determinant` / `inverse`
111
+ / `lstsq` / `cholesky` / `qr` accept `float64` and `complex128`; `eigh` / `svd`
112
+ are `float64` only (matching the C++ layer).
113
+
114
+ A `Tensor` is a citizen of the scientific Python stack, **zero-copy**:
115
+
116
+ ```python
117
+ import numpy as np, torch
118
+ np.asarray(t) # via __array_interface__ (a read-only view)
119
+ np.from_dlpack(t) # via __dlpack__
120
+ torch.from_dlpack(t) # the same DLPack capsule — JAX / CuPy consume it too
121
+ numerical.asarray(np.eye(3)) # the other direction (a contiguous-array copy)
122
+ ```
123
+
124
+ `numerical.get_include()` returns the header directory, so the C++ library can be
125
+ located through its Python install. `make python` builds the extension in place;
126
+ `make python-test` runs the binding suite — including a seeded **differential
127
+ fuzzer** that checks hundreds of random einsum specifications and linear-algebra
128
+ problems against NumPy within tolerance (when NumPy is importable, as in CI). PETSc (petsc4py) has no such exchange protocol — bridging it
129
+ would require an explicit copy into a PETSc object.
130
+
131
+ ## Benchmarks
132
+
133
+ NumericAL is validated against **NumPy** for both result and speed — `make
134
+ bench-python` checks every operation matches NumPy within a tolerance, then times
135
+ it; `make python-test` runs the correctness parity suite alone (also in CI). The
136
+ results and methodology, with an honest reading of the gap, are in
137
+ [BENCHMARKS.md](BENCHMARKS.md): NumericAL is a portable, dependency-free reference
138
+ implementation: correct within tolerance, and competitive with NumPy's own
139
+ `einsum`/`linalg` (it beats `np.einsum`'s non-BLAS path and the decompositions
140
+ land within ~1–4×). Against hand-tuned BLAS (`np.matmul`) its cache-blocked,
141
+ `std::thread`-parallel GEMM is ~10× slower but steady (no cache cliff) — that gap
142
+ is BLAS's per-architecture SIMD micro-kernel, which a header-only library does not
143
+ chase. See [BENCHMARKS.md](BENCHMARKS.md) for the honest details.
144
+
145
+ ## Numerical discipline
146
+
147
+ Floating-point accuracy is documented, never claimed exact where it cannot be;
148
+ results are deterministic given inputs and any tolerance/seed; differential
149
+ tests compare against references **within a documented tolerance**. Same gate
150
+ bar as the rest of the ecosystem: 100% coverage, clang **and** g++-14, lint,
151
+ format, and sanitizers green.
152
+
153
+ ## License
154
+
155
+ MIT — see [LICENSE](LICENSE).
156
+
157
+ ## Author
158
+
159
+ René Chenard
@@ -0,0 +1,51 @@
1
+ # Python distribution for NumericAL. Built from the repository root so the sdist is
2
+ # self-contained: it carries the C++ headers in include/ alongside the binding in
3
+ # python/. The C++ library itself is header-only and needs none of this — see the
4
+ # Makefile and CMakeLists.txt for the C++ workflows.
5
+ [build-system]
6
+ requires = ["setuptools>=68", "sciforge-build>=2026.6.16"]
7
+ build-backend = "setuptools.build_meta"
8
+
9
+ [project]
10
+ name = "numeric-al"
11
+ version = "2026.10.0"
12
+ description = "NumericAL — a generic, header-only numerical library: tensors and Einstein summation"
13
+ readme = "README.md"
14
+ requires-python = ">=3.10"
15
+ license = "MIT"
16
+ license-files = ["LICENSE"]
17
+ authors = [{ name = "René Chenard", email = "rene.chenard.1@ulaval.ca" }]
18
+ keywords = ["tensor", "einsum", "linear-algebra", "numerical", "dlpack", "array-interface"]
19
+ classifiers = [
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Developers",
22
+ "Intended Audience :: Science/Research",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3 :: Only",
25
+ "Programming Language :: C++",
26
+ "Topic :: Scientific/Engineering :: Mathematics",
27
+ "Topic :: Software Development :: Libraries",
28
+ "Operating System :: OS Independent",
29
+ ]
30
+
31
+ [project.urls]
32
+ Repository = "https://github.com/RECHE23/NumericAL"
33
+ Issues = "https://github.com/RECHE23/NumericAL/issues"
34
+
35
+ # The `numerical` package lives under python/; the C++ binding source under
36
+ # python/src; the headers it compiles against under include/ (root).
37
+ [tool.setuptools]
38
+ package-dir = { "" = "python" }
39
+ packages = ["numerical"]
40
+
41
+ [tool.setuptools.package-data]
42
+ numerical = ["*.so", "*.pyd"]
43
+
44
+ # Build one abi3 wheel per platform (cp310 → works on CPython 3.10+).
45
+ [tool.cibuildwheel]
46
+ build = "cp310-*"
47
+ build-frontend = "build"
48
+ test-command = "python -m unittest discover -s {project}/python/tests"
49
+
50
+ [tool.cibuildwheel.macos]
51
+ environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: numeric-al
3
+ Version: 2026.10.0
4
+ Summary: NumericAL — a generic, header-only numerical library: tensors and Einstein summation
5
+ Author-email: René Chenard <rene.chenard.1@ulaval.ca>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/RECHE23/NumericAL
8
+ Project-URL: Issues, https://github.com/RECHE23/NumericAL/issues
9
+ Keywords: tensor,einsum,linear-algebra,numerical,dlpack,array-interface
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: C++
16
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # NumericAL
25
+
26
+ A pure, header-only C++20 **numerical computing** library — a leaf of the
27
+ SciLang ecosystem (a sibling of [REAL](https://github.com/RECHE23/real-regex)),
28
+ generic over its scalar type and depending on nothing but the C++ standard
29
+ library.
30
+
31
+ NumericAL is **agnostic of expressions and of any symbolic layer**: it computes
32
+ with concrete numeric structures — vectors, matrices, tensors — and the
33
+ algorithms over them. SciLang consumes it as a numeric backend through its
34
+ module seam; the symbolic↔numeric reconciliation stays in SciLang.
35
+
36
+ ## Capabilities
37
+
38
+ Small and complete, grown measured, honest about what is not yet here:
39
+
40
+ - `numerical::vector<T>` — a dense, value-semantic vector: element-wise arithmetic,
41
+ scalar multiplication, dot product, tolerance comparison, shape checks.
42
+ - `numerical::matrix<T>` — a dense, row-major, value-semantic matrix: element-wise
43
+ arithmetic, scalar / matrix–vector / matrix–matrix products, transpose,
44
+ tolerance comparison, shape checks.
45
+ - `numerical::lu_decomposition<T>` — an LU factorisation (partial pivoting) computed
46
+ once and reused: `solve` (any number of right-hand sides), `determinant`, and
47
+ `inverse`. Free `solve` / `determinant` / `inverse` are one-shot conveniences.
48
+ - `numerical::cholesky_decomposition<T>` — `A = L Lᴴ` for a Hermitian
49
+ positive-definite matrix (about twice as cheap as LU): the factor `lower()`,
50
+ `solve`, and `determinant`; throws `not_positive_definite_error` otherwise.
51
+ - `numerical::qr_decomposition<T>` — `A = Q R` (modified Gram–Schmidt) for an
52
+ `m × n` matrix with `m ≥ n`: the factors `q()` / `r()` and a least-squares
53
+ `solve` of `A x ≈ b`; throws `singular_matrix_error` if the columns are dependent.
54
+ - `numerical::symmetric_eigen` — eigenvalues (ascending) and eigenvectors of a real
55
+ symmetric matrix by cyclic Jacobi rotations (`A = V Λ Vᵀ`).
56
+ - `numerical::svd_decomposition` — the singular value decomposition `A = U Σ Vᵀ`
57
+ of a real `m × n` matrix (`m ≥ n`), via the eigendecomposition of `Aᵀ A`:
58
+ `singular_values()` (descending), `u()`, `v()`.
59
+ - `numerical::tensor<T>` — a dense, row-major, N-dimensional tensor (rank-1 is a
60
+ vector, rank-2 a matrix, rank-0 a scalar; built directly or from a `vector` /
61
+ `matrix`), with **`einsum`** — Einstein-summation index notation for
62
+ contractions and general products, as in NumPy / PyTorch. `einsum` is the
63
+ unifying primitive of the algebra: `"ij,jk->ik"` is the matrix product,
64
+ `"i,i->"` the dot product, `"ij->ji"` the transpose, `"ii->"` the trace,
65
+ `"i,j->ij"` the outer product, `"ij->i"` a row reduction. It takes one or more
66
+ operands and sums over every label absent from the output, in a deterministic
67
+ order.
68
+
69
+ **Grows in as measured:** sparse storage, complex
70
+ Hermitian eigen/SVD, non-symmetric eigenvalues, FFT, numeric autodiff, iterative
71
+ solvers, numerical integration, arbitrary precision.
72
+
73
+ ## Build
74
+
75
+ ```bash
76
+ make test # build and run the test suite
77
+ make coverage # line-coverage summary + HTML report
78
+ make sanitize # tests under AddressSanitizer + UndefinedBehaviorSanitizer
79
+ make lint # clang-tidy
80
+ make format # uncrustify, in place
81
+ make doc # API reference (Doxygen) with embedded coverage
82
+ ```
83
+
84
+ Override the compiler with `make test CXX=g++-14`.
85
+
86
+ `numerical::numerical` is the CMake target — `add_subdirectory`, `FetchContent`, or an
87
+ installed config package:
88
+
89
+ ```cmake
90
+ # After `cmake --install <build> --prefix <prefix>`:
91
+ find_package(numerical CONFIG REQUIRED)
92
+ target_link_libraries(app PRIVATE numerical::numerical)
93
+ ```
94
+
95
+ ## Releasing
96
+
97
+ `make release` computes the next calendar version `YYYY.M.PATCH` — the patch
98
+ resets each month, the first release of a month is `.0` (PEP 440 drops leading
99
+ zeros, so `2026.6.1`, never `2026.06.001`) — bumps it in `pyproject.toml` and
100
+ `python/numerical/__init__.py`, then commits, tags and pushes from a clean `main`.
101
+ Pushing the tag drives `release.yml`, which checks the tag matches the version,
102
+ builds the abi3 wheels (Linux x86-64/aarch64, macOS universal, Windows) and the
103
+ sdist, and publishes to PyPI via Trusted Publishing (OIDC, no stored secret).
104
+
105
+ One-time PyPI setup (before the first release): create a
106
+ [Trusted Publisher](https://docs.pypi.org/trusted-publishers/) for the project
107
+ `numeric-al` — owner `RECHE23`, repository `NumericAL`, workflow `release.yml`,
108
+ environment `pypi` — and create the matching GitHub Environment named `pypi`.
109
+ Until that exists the build/sdist jobs still run, but the publish step fails;
110
+ the pushed tag remains a valid versioned snapshot regardless.
111
+
112
+ ## Python binding
113
+
114
+ ```sh
115
+ pip install numeric-al # the distribution is numeric-al; the module is numerical
116
+ ```
117
+
118
+ A CPython binding (stable ABI, one `cp310` abi3 wheel serves 3.10+) exposes the
119
+ unifying object `numerical.Tensor` (rank-1 a vector, rank-2 a matrix, rank-0 a
120
+ scalar; `float64` or `complex128`) and the algebra over it:
121
+
122
+ ```python
123
+ import numerical
124
+ a = numerical.Tensor([1, 2, 3, 4], shape=(2, 2))
125
+ b = numerical.Tensor([5, 6, 7, 8], shape=(2, 2))
126
+ numerical.einsum("ij,jk->ik", a, b) # matrix product
127
+ numerical.einsum("i,i->", numerical.Tensor([1, 2, 3]), numerical.Tensor([1, 2, 3])) # dot
128
+ numerical.solve(a, numerical.Tensor([1.0, 1.0])) # a @ x = b
129
+ ```
130
+
131
+ The decomposition layer is exposed too (a `numpy.linalg`-style surface):
132
+ `determinant(a)`, `inverse(a)`, `lstsq(a, b)`, `cholesky(a)`, `qr(a)` → `(Q, R)`,
133
+ `eigh(a)` → `(values, vectors)`, `svd(a)` → `(U, S, V)`. `determinant` / `inverse`
134
+ / `lstsq` / `cholesky` / `qr` accept `float64` and `complex128`; `eigh` / `svd`
135
+ are `float64` only (matching the C++ layer).
136
+
137
+ A `Tensor` is a citizen of the scientific Python stack, **zero-copy**:
138
+
139
+ ```python
140
+ import numpy as np, torch
141
+ np.asarray(t) # via __array_interface__ (a read-only view)
142
+ np.from_dlpack(t) # via __dlpack__
143
+ torch.from_dlpack(t) # the same DLPack capsule — JAX / CuPy consume it too
144
+ numerical.asarray(np.eye(3)) # the other direction (a contiguous-array copy)
145
+ ```
146
+
147
+ `numerical.get_include()` returns the header directory, so the C++ library can be
148
+ located through its Python install. `make python` builds the extension in place;
149
+ `make python-test` runs the binding suite — including a seeded **differential
150
+ fuzzer** that checks hundreds of random einsum specifications and linear-algebra
151
+ problems against NumPy within tolerance (when NumPy is importable, as in CI). PETSc (petsc4py) has no such exchange protocol — bridging it
152
+ would require an explicit copy into a PETSc object.
153
+
154
+ ## Benchmarks
155
+
156
+ NumericAL is validated against **NumPy** for both result and speed — `make
157
+ bench-python` checks every operation matches NumPy within a tolerance, then times
158
+ it; `make python-test` runs the correctness parity suite alone (also in CI). The
159
+ results and methodology, with an honest reading of the gap, are in
160
+ [BENCHMARKS.md](BENCHMARKS.md): NumericAL is a portable, dependency-free reference
161
+ implementation: correct within tolerance, and competitive with NumPy's own
162
+ `einsum`/`linalg` (it beats `np.einsum`'s non-BLAS path and the decompositions
163
+ land within ~1–4×). Against hand-tuned BLAS (`np.matmul`) its cache-blocked,
164
+ `std::thread`-parallel GEMM is ~10× slower but steady (no cache cliff) — that gap
165
+ is BLAS's per-architecture SIMD micro-kernel, which a header-only library does not
166
+ chase. See [BENCHMARKS.md](BENCHMARKS.md) for the honest details.
167
+
168
+ ## Numerical discipline
169
+
170
+ Floating-point accuracy is documented, never claimed exact where it cannot be;
171
+ results are deterministic given inputs and any tolerance/seed; differential
172
+ tests compare against references **within a documented tolerance**. Same gate
173
+ bar as the rest of the ecosystem: 100% coverage, clang **and** g++-14, lint,
174
+ format, and sanitizers green.
175
+
176
+ ## License
177
+
178
+ MIT — see [LICENSE](LICENSE).
179
+
180
+ ## Author
181
+
182
+ René Chenard
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ python/numeric_al.egg-info/PKG-INFO
6
+ python/numeric_al.egg-info/SOURCES.txt
7
+ python/numeric_al.egg-info/dependency_links.txt
8
+ python/numeric_al.egg-info/top_level.txt
9
+ python/numerical/__init__.py
10
+ python/src/_numerical.cpp