rust-num-lib 0.1.0__cp39-abi3-win32.whl

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,2 @@
1
+ from .rust_num_lib import * # noqa: F401,F403
2
+ from .rust_num_lib import linalg, stats # noqa: F401
@@ -0,0 +1,3 @@
1
+ """rust_num_lib — a scientific computing library written in Rust."""
2
+ from . import linalg as linalg
3
+ from . import stats as stats
@@ -0,0 +1,176 @@
1
+ """Linear algebra module: matrices, factorizations, eigenvalues, solving systems."""
2
+ from typing import Optional
3
+
4
+
5
+ class Matrix:
6
+ """A dense row-major matrix of f64 values."""
7
+
8
+ def __init__(self, rows: int, cols: int) -> None:
9
+ """Create a new zero-filled matrix of shape (rows, cols)."""
10
+ ...
11
+
12
+ @staticmethod
13
+ def zeros(rows: int, cols: int) -> "Matrix":
14
+ """Create a (rows x cols) matrix filled with zeros."""
15
+ ...
16
+
17
+ @staticmethod
18
+ def identity(size: int) -> "Matrix":
19
+ """Create a (size x size) identity matrix."""
20
+ ...
21
+
22
+ @staticmethod
23
+ def random(rows: int, cols: int, min: float, max: float) -> "Matrix":
24
+ """Create a (rows x cols) matrix with values drawn uniformly from [min, max)."""
25
+ ...
26
+
27
+ @staticmethod
28
+ def from_data(data: list[float], rows: int, cols: int) -> "Matrix":
29
+ """Create a matrix from a flat row-major list. len(data) must equal rows * cols."""
30
+ ...
31
+
32
+ @property
33
+ def rows(self) -> int:
34
+ """Number of rows."""
35
+ ...
36
+
37
+ @property
38
+ def cols(self) -> int:
39
+ """Number of columns."""
40
+ ...
41
+
42
+ def transpose(self) -> "Matrix":
43
+ """Return the transpose as a new matrix."""
44
+ ...
45
+
46
+ def determinant(self) -> float:
47
+ """Determinant of a square matrix (via LU factorization)."""
48
+ ...
49
+
50
+ def trace(self) -> float:
51
+ """Sum of the diagonal elements."""
52
+ ...
53
+
54
+ def norm(self) -> float:
55
+ """Frobenius norm: sqrt of the sum of squared elements."""
56
+ ...
57
+
58
+ def rank(self) -> int:
59
+ """Rank: number of non-zero pivots from LU factorization."""
60
+ ...
61
+
62
+ def eigenvalues(self, steps: Optional[int] = None) -> list[float]:
63
+ """Eigenvalues, approximated with the QR algorithm.
64
+
65
+ :param steps: number of QR iterations (default: built-in value).
66
+ :return: list of eigenvalues.
67
+ """
68
+ ...
69
+
70
+ def eigenvectors(self, steps: Optional[int] = None) -> tuple[list[float], list["Matrix"]]:
71
+ """Eigenvalues and eigenvectors.
72
+
73
+ :param steps: number of QR iterations.
74
+ :return: tuple (eigenvalues, eigenvectors) where each eigenvector is a column Matrix.
75
+ """
76
+ ...
77
+
78
+ def row(self, i: int) -> "Matrix":
79
+ """Return row i as a (1 x cols) matrix."""
80
+ ...
81
+
82
+ def col(self, i: int) -> "Matrix":
83
+ """Return column i as a (rows x 1) matrix."""
84
+ ...
85
+
86
+ def slice(
87
+ self,
88
+ row_range: Optional[tuple[int, int]] = None,
89
+ row_step: Optional[int] = None,
90
+ col_range: Optional[tuple[int, int]] = None,
91
+ col_step: Optional[int] = None,
92
+ ) -> "Matrix":
93
+ """Extract a sub-matrix with optional (start, end) ranges and steps per axis.
94
+
95
+ Negative steps reverse the axis. None selects the full axis.
96
+ """
97
+ ...
98
+
99
+ def apply_along_axis(self, f: "callable", axis: int) -> "Matrix":
100
+ """Apply f to each row or column, reducing it to a single value.
101
+
102
+ :param f: callable taking a Matrix (row/column) and returning a float.
103
+ :param axis: 0 applies f to each column (result 1 x cols),
104
+ 1 applies f to each row (result rows x 1).
105
+ """
106
+ ...
107
+
108
+ def __matmul__(self, other: "Matrix") -> "Matrix":
109
+ """Matrix multiplication (the @ operator)."""
110
+ ...
111
+
112
+ def __add__(self, other: "Matrix") -> "Matrix":
113
+ """Element-wise matrix addition."""
114
+ ...
115
+
116
+ def __mul__(self, scalar: float) -> "Matrix":
117
+ """Scalar multiplication (matrix * scalar)."""
118
+ ...
119
+
120
+ def __rmul__(self, scalar: float) -> "Matrix":
121
+ """Scalar multiplication (scalar * matrix)."""
122
+ ...
123
+
124
+ def __getitem__(self, idx: tuple[int, int]) -> float:
125
+ """Element access: m[i, j]."""
126
+ ...
127
+
128
+ def __setitem__(self, idx: tuple[int, int], value: float) -> None:
129
+ """Element assignment: m[i, j] = value."""
130
+ ...
131
+
132
+
133
+ def matrix(data: list[list[float]]) -> Matrix:
134
+ """Build a matrix from a 2D list, inferring dimensions from its shape.
135
+
136
+ All rows must have the same length.
137
+ """
138
+ ...
139
+
140
+
141
+ def vector(data: list[float]) -> Matrix:
142
+ """Build a column vector (n x 1 matrix) from a flat list."""
143
+ ...
144
+
145
+
146
+ def matmul_chained(matrices: list[Matrix]) -> Matrix:
147
+ """Multiply a chain of matrices using an optimal multiplication order."""
148
+ ...
149
+
150
+
151
+ def solve(a: Matrix, b: Matrix) -> Matrix:
152
+ """Solve the linear system A x = b for x."""
153
+ ...
154
+
155
+
156
+ def solve_multiple(a: Matrix, bs: list[Matrix]) -> list[Matrix]:
157
+ """Solve A x = b for multiple right-hand sides, factorizing A once."""
158
+ ...
159
+
160
+
161
+ def qr_factorize(a: Matrix) -> tuple[Matrix, Matrix]:
162
+ """QR factorization. Returns (Q, R) with Q orthonormal, R upper triangular, A = Q R."""
163
+ ...
164
+
165
+
166
+ def lu_factorize(a: Matrix) -> tuple[Matrix, Matrix, list[int]]:
167
+ """LU factorization with partial pivoting. Returns (L, U, perm) such that P A = L U."""
168
+ ...
169
+
170
+
171
+ def cholesky(a: Matrix) -> Matrix:
172
+ """Cholesky factorization of a symmetric positive-definite matrix.
173
+
174
+ Returns lower-triangular L such that A = L Lᵀ.
175
+ """
176
+ ...
rust_num_lib/py.typed ADDED
File without changes
Binary file
rust_num_lib/stats.pyi ADDED
@@ -0,0 +1,40 @@
1
+ """Statistics module: descriptive statistics and sampling from distributions."""
2
+ from .linalg import Matrix
3
+
4
+
5
+ def mean(m: Matrix) -> float:
6
+ """Arithmetic mean of all elements in the matrix."""
7
+ ...
8
+
9
+
10
+ def median(m: Matrix) -> float:
11
+ """Median of all elements in the matrix."""
12
+ ...
13
+
14
+
15
+ def std_dev(m: Matrix) -> float:
16
+ """Standard deviation of all elements in the matrix."""
17
+ ...
18
+
19
+
20
+ def variance(m: Matrix) -> float:
21
+ """Variance of all elements in the matrix."""
22
+ ...
23
+
24
+
25
+ def normal_sample(n: int, mu: float, sigma: float) -> Matrix:
26
+ """Draw n samples from a normal distribution N(mu, sigma^2).
27
+
28
+ :return: an (n x 1) column vector of samples.
29
+ """
30
+ ...
31
+
32
+
33
+ def multivariate_normal_sample(n_samples: int, mu: Matrix, sigma: Matrix) -> Matrix:
34
+ """Draw samples from a multivariate normal distribution N(mu, Sigma).
35
+
36
+ :param mu: mean vector.
37
+ :param sigma: covariance matrix (symmetric positive-definite).
38
+ :return: an (n_samples x dim) matrix where each row is one sample.
39
+ """
40
+ ...
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.4
2
+ Name: rust-num-lib
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Science/Research
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Rust
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
10
+ Classifier: Typing :: Typed
11
+ License-File: LICENSE
12
+ Summary: Scientific computing library written in Rust: linear algebra and statistics
13
+ Keywords: linear algebra,matrix,statistics,rust
14
+ Author-email: Wiktor Augustyn <wiktoraugustyn2005@gmail.com>
15
+ License: MIT
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
18
+ Project-URL: Documentation, https://github.com/wiktor6741/rust_num_lib/blob/main/docs/rust_num_lib.pdf
19
+ Project-URL: Repository, https://github.com/wiktor6741/rust_num_lib
20
+
21
+ # rust_num_lib
22
+
23
+ A scientific computing library written in Rust, with Python bindings via [PyO3](https://pyo3.rs/).
24
+
25
+ The goal of this project is to provide fast, low-level implementations of numerical algorithms (linear algebra, statistics) with a convenient Python interface — combining Rust's performance with Python's ergonomics.
26
+
27
+ ## Modules
28
+
29
+ - **`rust_num_lib.linalg`** — linear algebra: matrix multiplication, factorizations (LU, QR, Cholesky), solving linear systems, eigenvalues and eigenvectors.
30
+ - **`rust_num_lib.stats`** — statistics: mean, standard deviation, sampling from distributions, data generation.
31
+
32
+ ## Requirements
33
+
34
+ - [Rust](https://www.rust-lang.org/tools/install) (stable toolchain, 2024 edition — Rust 1.85+)
35
+ - Python 3.8+
36
+ - [maturin](https://www.maturin.rs/) — tool for building Python extensions from Rust
37
+
38
+ ## Installation and Setup
39
+
40
+ The library is not (yet) published on PyPI, so it has to be built locally from source using `maturin`.
41
+
42
+ ### 1. Clone the repository
43
+
44
+ ```bash
45
+ git clone <repository-url>
46
+ cd rust_num_lib
47
+ ```
48
+
49
+ ### 2. Create and activate a virtual environment
50
+
51
+ Using a clean `venv` is recommended (not conda — mixing the two causes conflicts during the build):
52
+
53
+ ```bash
54
+ python3 -m venv .venv
55
+ source .venv/bin/activate # Linux / macOS
56
+ # .venv\Scripts\activate # Windows
57
+ ```
58
+
59
+ > **Note:** if you have a conda environment active, deactivate it first (`conda deactivate`), because `maturin` will refuse to build when both `VIRTUAL_ENV` and `CONDA_PREFIX` are set.
60
+
61
+ ### 3. Install maturin
62
+
63
+ ```bash
64
+ pip install maturin
65
+ ```
66
+
67
+ ### 4. Build and install the library
68
+
69
+ ```bash
70
+ maturin develop --release
71
+ ```
72
+
73
+ The `--release` flag matters — without it the code compiles in debug mode (no optimizations), which is many times slower and unsuitable for benchmarking.
74
+
75
+ This command builds the extension and installs it into the active virtual environment.
76
+
77
+ ### 5. Verify it works
78
+
79
+ ```python
80
+ import rust_num_lib.linalg as linalg
81
+
82
+ a = linalg.Matrix.identity(3)
83
+ print(a)
84
+ ```
85
+
86
+ ## Tests
87
+
88
+ Unit tests (pure Rust, without PyO3) are run via Cargo:
89
+
90
+ ```bash
91
+ cargo test
92
+ ```
93
+
94
+ ## Project Structure
95
+
96
+ ```
97
+ rust_num_lib/
98
+ ├── src/
99
+ │ ├── lib.rs # entry point, PyO3 module registration
100
+ │ ├── python.rs # Python bindings for Matrix methods
101
+ │ ├── linalg/ # linear algebra module
102
+ │ └── stats/ # statistics module
103
+ ├── Cargo.toml
104
+ ├── pyproject.toml
105
+ └── README.md
106
+ ```
@@ -0,0 +1,11 @@
1
+ rust_num_lib/__init__.py,sha256=_dpgEmGUJMcF6BhNLq2qy2inafU5nAquqSJpi12GHzw,103
2
+ rust_num_lib/__init__.pyi,sha256=JY4SeAlubKMWZhjkkbg2T74umLmdQhlNEVoxW7ce_0o,134
3
+ rust_num_lib/linalg.pyi,sha256=T_M-3DMq3J2xnJycMiynDKcPkXzkLo4JJVesr6EVKhQ,5324
4
+ rust_num_lib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ rust_num_lib/rust_num_lib.pyd,sha256=aY3sqD3s548_osF_cI6EbpUDJsivSgn3nxAWK1iz6Wc,429056
6
+ rust_num_lib/stats.pyi,sha256=_-4AVlvge5KGYqRGX5-i-VnT43CMkF0TufAuH3Apll8,1072
7
+ rust_num_lib-0.1.0.dist-info/METADATA,sha256=ZPEkk5Y60HYfK5hMHVjejsQ57RgONuMPz70RudLbKKY,3436
8
+ rust_num_lib-0.1.0.dist-info/WHEEL,sha256=8ST325XFG2q3xFayPLTIr9sdq1tqsT7cdb0g_IYiXZ8,91
9
+ rust_num_lib-0.1.0.dist-info/licenses/LICENSE,sha256=66_JZUpPhIhQf_7O0RkskXGRHBSlyZWQT6DBSY33noM,1093
10
+ rust_num_lib-0.1.0.dist-info/sboms/rust_num_lib.cyclonedx.json,sha256=3gfiK_TKa9RFbI4Xkat5Dot9C3ATYNwcJM1vYE9meUE,31406
11
+ rust_num_lib-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.16.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp39-abi3-win32
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wiktor Augustyn
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.