nrumpy 0.1.0__cp313-cp313-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.
- nrumpy-0.1.0.dist-info/METADATA +90 -0
- nrumpy-0.1.0.dist-info/RECORD +11 -0
- nrumpy-0.1.0.dist-info/WHEEL +4 -0
- nrumpy-0.1.0.dist-info/sboms/rumpy-core.cyclonedx.json +920 -0
- rumpy/__init__.py +43 -0
- rumpy/__init__.pyi +111 -0
- rumpy/_convert.py +203 -0
- rumpy/core.py +199 -0
- rumpy/errors.py +53 -0
- rumpy/py.typed +0 -0
- rumpy/rumpy_core.cp313-win32.pyd +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nrumpy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Intended Audience :: Science/Research
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Rust
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Dist: numpy>=1.26
|
|
17
|
+
Requires-Dist: pytest>=8 ; extra == 'test'
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Summary: Strassen matrix multiplication for NumPy arrays and nested lists
|
|
20
|
+
Keywords: matrix,linear-algebra,strassen,numpy
|
|
21
|
+
Author-email: Jayadithya Dhurwey <jayadithya.dhurwey@gmail.com>
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
24
|
+
Project-URL: Documentation, https://github.com/jaysit-gif/rumpy/blob/main/DOCS.md
|
|
25
|
+
Project-URL: Homepage, https://github.com/jaysit-gif/rumpy
|
|
26
|
+
Project-URL: Repository, https://github.com/jaysit-gif/rumpy
|
|
27
|
+
|
|
28
|
+
# rumpy
|
|
29
|
+
|
|
30
|
+
`rumpy-core` multiplies row-major `f64` matrices with Strassen's algorithm.
|
|
31
|
+
|
|
32
|
+
Library documentation: [DOCS.md](DOCS.md).
|
|
33
|
+
|
|
34
|
+
## Algorithm
|
|
35
|
+
|
|
36
|
+
Strassen splits a square into four quadrants and forms seven products instead of eight:
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
M1 = (A11 + A22) (B11 + B22)
|
|
40
|
+
M2 = (A21 + A22) B11
|
|
41
|
+
M3 = A11 (B12 - B22)
|
|
42
|
+
M4 = A22 (B21 - B11)
|
|
43
|
+
M5 = (A11 + A12) B22
|
|
44
|
+
M6 = (A21 - A11) (B11 + B12)
|
|
45
|
+
M7 = (A12 - A22) (B21 + B22)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The quadrants of the product are
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
C11 = M1 + M4 - M5 + M7
|
|
52
|
+
C12 = M3 + M5
|
|
53
|
+
C21 = M2 + M4
|
|
54
|
+
C22 = M1 - M2 + M3 + M6
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Each product uses the same recurrence until the side is at most `leaf_size`, then a cache-blocked triple loop. `leaf_size == 0` skips Strassen and uses the plain triple loop. `matmul_parallel` runs the seven products with `rayon::join` while the side is at least 256.
|
|
58
|
+
|
|
59
|
+
## Padding
|
|
60
|
+
|
|
61
|
+
The recursive step needs a square whose side is a power of two. `matmul` accepts any compatible shapes `m×k` and `k×n`. Let `s` be the next power of two of `max(m, k, n)`. Each input is copied into the top-left of an `s×s` matrix of zeros, those squares are multiplied, and the result is the top-left `m×n` block. The extra zeros do not change the product. A `5×7` times a `7×3` pads to `8×8` and crops back to `5×3`. A square that is already a power of two is copied as itself.
|
|
62
|
+
|
|
63
|
+
A zero side is not padded. `next_power_of_two(0)` is `1`, which would turn an empty product into a `1×1`, so a zero side uses the triple loop on the original shapes. `leaf_size == 0` takes that same path.
|
|
64
|
+
|
|
65
|
+
## Python
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from rumpy import matmul
|
|
69
|
+
|
|
70
|
+
matmul([[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]])
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`matmul` accepts nested lists, tuples of rows, and 2-D NumPy arrays. A NumPy left-hand matrix returns a `float64` array. Any other left-hand matrix returns a nested list. `leaf_size` defaults to 64. `leaf_size=0` skips Strassen and uses the plain triple loop. Importing `rumpy` does not require the extension to be built.
|
|
74
|
+
|
|
75
|
+
`pyproject.toml` sets `extension-module`, so these commands from the repository root pass that feature through:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# editable install, debug
|
|
79
|
+
maturin develop
|
|
80
|
+
|
|
81
|
+
# editable install, release
|
|
82
|
+
maturin develop --release
|
|
83
|
+
|
|
84
|
+
# wheel, then install
|
|
85
|
+
maturin build --release
|
|
86
|
+
pip install target/wheels/rumpy-*.whl
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`make dev`, `make test`, `make fmt`, and `make lint` run those steps from the repository root. `make dev` is `maturin develop --release`.
|
|
90
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
nrumpy-0.1.0.dist-info/METADATA,sha256=NdGVoySQf36iRt2LEudMVnpCYU9Fbnh39akWEEfO4g0,3654
|
|
2
|
+
nrumpy-0.1.0.dist-info/WHEEL,sha256=6LxxOGCOtVf3GF1crQlX-l07lHAdb0nn6xhtazAwN-A,93
|
|
3
|
+
nrumpy-0.1.0.dist-info/sboms/rumpy-core.cyclonedx.json,sha256=w2orj2PdP3FS0tKoN5zfvl7TVxOkdLHRNiXCFAMM_WU,27797
|
|
4
|
+
rumpy/__init__.py,sha256=WzV1OIwXL96c_57Y3jUTVeB3OkvJHrhOBnuPOenLyTY,979
|
|
5
|
+
rumpy/__init__.pyi,sha256=c3frF5yguMugKW3wUwhOpIBTlwB-kjLVsf6jmjpQxk8,3062
|
|
6
|
+
rumpy/_convert.py,sha256=153nyNPZzOyFn1huSZzv6CgExba8yY470pDxtNQ6Ew0,7045
|
|
7
|
+
rumpy/core.py,sha256=sdkuzwqtOG_RjHtFcOD3RP8Fok6YBYIDq1Bc6QobSp4,7321
|
|
8
|
+
rumpy/errors.py,sha256=ErKMLoqVg9xOa-KX5vKUWyUw4oZ5tH95W3PALCryxzU,1619
|
|
9
|
+
rumpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
rumpy/rumpy_core.cp313-win32.pyd,sha256=ApJNQtNpvpE8Q4ZBkcPPOsqv4aNsBDDTAHudvgoeBDI,349184
|
|
11
|
+
nrumpy-0.1.0.dist-info/RECORD,,
|