panchi 0.1.0a1__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.
- panchi-0.1.0a1/LICENSE +21 -0
- panchi-0.1.0a1/MANIFEST.in +10 -0
- panchi-0.1.0a1/PKG-INFO +271 -0
- panchi-0.1.0a1/README.md +226 -0
- panchi-0.1.0a1/panchi/__init__.py +46 -0
- panchi-0.1.0a1/panchi/algorithms/__init__.py +20 -0
- panchi-0.1.0a1/panchi/algorithms/decompositions.py +35 -0
- panchi-0.1.0a1/panchi/algorithms/reductions.py +289 -0
- panchi-0.1.0a1/panchi/algorithms/results.py +471 -0
- panchi-0.1.0a1/panchi/algorithms/row_operations.py +802 -0
- panchi-0.1.0a1/panchi/primitives/__init__.py +8 -0
- panchi-0.1.0a1/panchi/primitives/factories.py +468 -0
- panchi-0.1.0a1/panchi/primitives/matrix.py +1110 -0
- panchi-0.1.0a1/panchi/primitives/vector.py +464 -0
- panchi-0.1.0a1/panchi/primitives/vector_operations.py +87 -0
- panchi-0.1.0a1/panchi/py.typed +0 -0
- panchi-0.1.0a1/panchi/visualizations/__init__.py +38 -0
- panchi-0.1.0a1/panchi/visualizations/animators/animator_2d.py +13 -0
- panchi-0.1.0a1/panchi/visualizations/backends/__init__.py +1 -0
- panchi-0.1.0a1/panchi/visualizations/backends/manim_2d.py +389 -0
- panchi-0.1.0a1/panchi/visualizations/backends/matplotlib_2d.py +310 -0
- panchi-0.1.0a1/panchi.egg-info/PKG-INFO +271 -0
- panchi-0.1.0a1/panchi.egg-info/SOURCES.txt +26 -0
- panchi-0.1.0a1/panchi.egg-info/dependency_links.txt +1 -0
- panchi-0.1.0a1/panchi.egg-info/requires.txt +18 -0
- panchi-0.1.0a1/panchi.egg-info/top_level.txt +1 -0
- panchi-0.1.0a1/pyproject.toml +115 -0
- panchi-0.1.0a1/setup.cfg +4 -0
panchi-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gustavo Galvao e Silva
|
|
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.
|
panchi-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: panchi
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: A Python-native linear algebra library for learning, experimentation, and visual intuition
|
|
5
|
+
Author-email: Gustavo Galvao e Silva <gustavo.galvaoesilva@gmail.com>
|
|
6
|
+
Maintainer-email: Gustavo Galvao e Silva <gustavo.galvaoesilva@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/Gustavo-Galvao-e-Silva/panchi
|
|
9
|
+
Project-URL: Documentation, https://github.com/Gustavo-Galvao-e-Silva/panchi#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/Gustavo-Galvao-e-Silva/panchi
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/Gustavo-Galvao-e-Silva/panchi/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/Gustavo-Galvao-e-Silva/panchi/releases
|
|
13
|
+
Keywords: linear algebra,mathematics,education,vectors,matrices,visualization
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Education
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Education
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
31
|
+
Provides-Extra: manim
|
|
32
|
+
Requires-Dist: manim>=0.18.0; extra == "manim"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
36
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
37
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
38
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
41
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
42
|
+
Provides-Extra: all
|
|
43
|
+
Requires-Dist: panchi[dev,manim]; extra == "all"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# panchi
|
|
47
|
+
|
|
48
|
+
**panchi** is a Python-native linear algebra library designed for learning, experimentation, and visual intuition.
|
|
49
|
+
|
|
50
|
+
The goal is not performance. The goal is **clarity**.
|
|
51
|
+
|
|
52
|
+
[](https://github.com/Gustavo-Galvao-e-Silva/panchi/actions/workflows/panchi-test.yml)
|
|
53
|
+
[](https://pypi.org/project/panchi/)
|
|
54
|
+
[](https://www.python.org/downloads/)
|
|
55
|
+
[](https://opensource.org/licenses/MIT)
|
|
56
|
+
[](https://github.com/psf/black)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Why panchi?
|
|
61
|
+
|
|
62
|
+
Most linear algebra libraries optimize for speed and abstraction. panchi optimizes for **understanding**.
|
|
63
|
+
|
|
64
|
+
panchi is built for:
|
|
65
|
+
- **Students** learning linear algebra who want to see the math happen, not just trust a black box
|
|
66
|
+
- **Educators** who need transparent implementations to demonstrate concepts in lectures or workshops
|
|
67
|
+
- **Self-learners** building intuition through experimentation and visual feedback
|
|
68
|
+
- **Researchers** prototyping algorithms where readability matters more than runtime
|
|
69
|
+
- **Developers** who want to understand what's happening under the hood before optimizing
|
|
70
|
+
|
|
71
|
+
Think of panchi as a **laboratory notebook**, not a production engine.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Philosophy
|
|
76
|
+
|
|
77
|
+
1. **Explicit over implicit** – Algorithms are implemented directly, not delegated to opaque backends
|
|
78
|
+
2. **Readable over clever** – Code prioritizes clarity and educational value over terse optimizations
|
|
79
|
+
3. **Mathematical over computational** – Objects behave like mathematical entities with proper operator overloading
|
|
80
|
+
4. **Visual by default** – Visualization is a first-class feature, not an afterthought
|
|
81
|
+
5. **Informative errors** – Error messages guide learning by explaining what went wrong and why
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
### ✅ Currently Available
|
|
88
|
+
|
|
89
|
+
**Core Primitives**
|
|
90
|
+
- `Vector` and `Matrix` classes with native Python data structures
|
|
91
|
+
- Natural mathematical syntax through operator overloading (`+`, `-`, `*`, `**`)
|
|
92
|
+
- Comprehensive shape checking with educational error messages
|
|
93
|
+
|
|
94
|
+
**Vector Operations**
|
|
95
|
+
- Addition, subtraction, scalar multiplication
|
|
96
|
+
- Magnitude calculation and normalization
|
|
97
|
+
- Dot product and cross product (3D)
|
|
98
|
+
- Unit vectors and zero vectors
|
|
99
|
+
|
|
100
|
+
**Matrix Operations**
|
|
101
|
+
- Addition, subtraction, matrix multiplication
|
|
102
|
+
- Scalar multiplication and matrix powers
|
|
103
|
+
- Transpose operations
|
|
104
|
+
- Matrix-vector transformations
|
|
105
|
+
- Trace calculation for square matrices
|
|
106
|
+
|
|
107
|
+
**Utilities**
|
|
108
|
+
- Identity matrices and zero matrices
|
|
109
|
+
- Random vectors and matrices with configurable ranges
|
|
110
|
+
- 2D and 3D rotation matrices
|
|
111
|
+
- Diagonal matrix construction
|
|
112
|
+
|
|
113
|
+
### 🚧 In Development
|
|
114
|
+
|
|
115
|
+
- Matrix determinants and inverses
|
|
116
|
+
- Matrix decompositions (LU, QR, eigenvalue methods)
|
|
117
|
+
- Interactive visualization toolkit
|
|
118
|
+
- Animated transformations
|
|
119
|
+
- Jupyter notebook integration
|
|
120
|
+
|
|
121
|
+
### 🔮 Roadmap
|
|
122
|
+
|
|
123
|
+
- Step-by-step algorithm demonstrations
|
|
124
|
+
- Educational machine learning examples (PCA, linear regression)
|
|
125
|
+
- Physics simulations using linear operators
|
|
126
|
+
- Extended documentation with visual explanations
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Installation
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pip install panchi
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Requirements:** Python 3.10 or higher
|
|
137
|
+
|
|
138
|
+
For the optional Manim-powered visualizations:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
pip install panchi[manim]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
To install from source for development:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
git clone https://github.com/Gustavo-Galvao-e-Silva/panchi.git
|
|
148
|
+
cd panchi
|
|
149
|
+
pip install -e ".[dev]"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Quick Start
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from panchi.primitives import Vector, Matrix
|
|
158
|
+
from panchi.operations import dot, identity, rotation_matrix_2d
|
|
159
|
+
from math import pi
|
|
160
|
+
|
|
161
|
+
# Vector operations
|
|
162
|
+
v = Vector([3, 4])
|
|
163
|
+
magnitude = v.magnitude
|
|
164
|
+
normalized = v.normalize()
|
|
165
|
+
|
|
166
|
+
# Matrix transformations
|
|
167
|
+
rotation = rotation_matrix_2d(pi / 2)
|
|
168
|
+
point = Vector([1, 0])
|
|
169
|
+
rotated = rotation * point
|
|
170
|
+
|
|
171
|
+
# Matrix algebra
|
|
172
|
+
A = Matrix([[1, 2], [3, 4]])
|
|
173
|
+
B = Matrix([[5, 6], [7, 8]])
|
|
174
|
+
C = A * B
|
|
175
|
+
trace = C.trace
|
|
176
|
+
|
|
177
|
+
# Identity and special matrices
|
|
178
|
+
I = identity(3)
|
|
179
|
+
product = A * A.right_identity
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Use Cases
|
|
185
|
+
|
|
186
|
+
### 1. **Learning Linear Algebra**
|
|
187
|
+
Work through textbook problems with code that mirrors mathematical notation:
|
|
188
|
+
```python
|
|
189
|
+
# Verify that (AB)^T = B^T A^T
|
|
190
|
+
A = Matrix([[1, 2], [3, 4]])
|
|
191
|
+
B = Matrix([[5, 6], [7, 8]])
|
|
192
|
+
|
|
193
|
+
left_side = (A * B).T
|
|
194
|
+
right_side = B.T * A.T
|
|
195
|
+
|
|
196
|
+
assert left_side == right_side
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Contributing
|
|
202
|
+
|
|
203
|
+
panchi welcomes contributions that align with its educational mission:
|
|
204
|
+
|
|
205
|
+
1. **Clarity First** – Code should be readable by someone learning linear algebra
|
|
206
|
+
2. **Tests Required** – All new features need comprehensive pytest tests
|
|
207
|
+
3. **Descriptive Docstrings** – Follow NumPy documentation style
|
|
208
|
+
4. **Mathematical Accuracy** – Verify implementations against textbook algorithms
|
|
209
|
+
|
|
210
|
+
### How to Contribute
|
|
211
|
+
|
|
212
|
+
1. Fork the repository
|
|
213
|
+
2. Create a feature branch (`git checkout -b feature/determinant-calculation`)
|
|
214
|
+
3. Write clear, well-documented code with tests
|
|
215
|
+
4. Ensure all tests pass (`pytest tests/`)
|
|
216
|
+
5. Submit a pull request with a detailed description
|
|
217
|
+
|
|
218
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Documentation
|
|
223
|
+
|
|
224
|
+
Full documentation will be available at [panchi.readthedocs.io](https://panchi.readthedocs.io) *(coming soon)*
|
|
225
|
+
|
|
226
|
+
- **API Reference** – Complete function and class documentation
|
|
227
|
+
- **Tutorials** – Step-by-step guides for common operations
|
|
228
|
+
- **Examples** – Real-world use cases and demonstrations
|
|
229
|
+
- **Theory** – Mathematical background and explanations
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Project Status
|
|
234
|
+
|
|
235
|
+
**Current Version:** 0.1.0a1 (Alpha)
|
|
236
|
+
|
|
237
|
+
panchi is in early alpha. It is installable and the core primitives are functional, but APIs may change as the library evolves. Not recommended for production use. Feedback and contributions are very welcome.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Support
|
|
242
|
+
|
|
243
|
+
- **Issues:** Report bugs or request features via [GitHub Issues](https://github.com/Gustavo-Galvao-e-Silva/panchi/issues)
|
|
244
|
+
- **Discussions:** Ask questions in [GitHub Discussions](https://github.com/Gustavo-Galvao-e-Silva/panchi/discussions)
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
MIT License – see [LICENSE](LICENSE) for details.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Acknowledgments
|
|
255
|
+
|
|
256
|
+
panchi is inspired by educational resources that prioritize understanding:
|
|
257
|
+
- Gilbert Strang's *Introduction to Linear Algebra*
|
|
258
|
+
- 3Blue1Brown's *Essence of Linear Algebra* video series
|
|
259
|
+
- The desire to make linear algebra accessible and visual
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Final Note
|
|
264
|
+
|
|
265
|
+
panchi exists to answer a simple question:
|
|
266
|
+
|
|
267
|
+
> **"What is linear algebra actually *doing*?"**
|
|
268
|
+
|
|
269
|
+
If you've ever felt frustrated by libraries that hide the mathematics behind abstractions, or if you want to *see* transformations happen rather than just trust the output, panchi is for you.
|
|
270
|
+
|
|
271
|
+
Linear algebra is beautiful. Let's make it visible.
|
panchi-0.1.0a1/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# panchi
|
|
2
|
+
|
|
3
|
+
**panchi** is a Python-native linear algebra library designed for learning, experimentation, and visual intuition.
|
|
4
|
+
|
|
5
|
+
The goal is not performance. The goal is **clarity**.
|
|
6
|
+
|
|
7
|
+
[](https://github.com/Gustavo-Galvao-e-Silva/panchi/actions/workflows/panchi-test.yml)
|
|
8
|
+
[](https://pypi.org/project/panchi/)
|
|
9
|
+
[](https://www.python.org/downloads/)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
[](https://github.com/psf/black)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why panchi?
|
|
16
|
+
|
|
17
|
+
Most linear algebra libraries optimize for speed and abstraction. panchi optimizes for **understanding**.
|
|
18
|
+
|
|
19
|
+
panchi is built for:
|
|
20
|
+
- **Students** learning linear algebra who want to see the math happen, not just trust a black box
|
|
21
|
+
- **Educators** who need transparent implementations to demonstrate concepts in lectures or workshops
|
|
22
|
+
- **Self-learners** building intuition through experimentation and visual feedback
|
|
23
|
+
- **Researchers** prototyping algorithms where readability matters more than runtime
|
|
24
|
+
- **Developers** who want to understand what's happening under the hood before optimizing
|
|
25
|
+
|
|
26
|
+
Think of panchi as a **laboratory notebook**, not a production engine.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Philosophy
|
|
31
|
+
|
|
32
|
+
1. **Explicit over implicit** – Algorithms are implemented directly, not delegated to opaque backends
|
|
33
|
+
2. **Readable over clever** – Code prioritizes clarity and educational value over terse optimizations
|
|
34
|
+
3. **Mathematical over computational** – Objects behave like mathematical entities with proper operator overloading
|
|
35
|
+
4. **Visual by default** – Visualization is a first-class feature, not an afterthought
|
|
36
|
+
5. **Informative errors** – Error messages guide learning by explaining what went wrong and why
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
### ✅ Currently Available
|
|
43
|
+
|
|
44
|
+
**Core Primitives**
|
|
45
|
+
- `Vector` and `Matrix` classes with native Python data structures
|
|
46
|
+
- Natural mathematical syntax through operator overloading (`+`, `-`, `*`, `**`)
|
|
47
|
+
- Comprehensive shape checking with educational error messages
|
|
48
|
+
|
|
49
|
+
**Vector Operations**
|
|
50
|
+
- Addition, subtraction, scalar multiplication
|
|
51
|
+
- Magnitude calculation and normalization
|
|
52
|
+
- Dot product and cross product (3D)
|
|
53
|
+
- Unit vectors and zero vectors
|
|
54
|
+
|
|
55
|
+
**Matrix Operations**
|
|
56
|
+
- Addition, subtraction, matrix multiplication
|
|
57
|
+
- Scalar multiplication and matrix powers
|
|
58
|
+
- Transpose operations
|
|
59
|
+
- Matrix-vector transformations
|
|
60
|
+
- Trace calculation for square matrices
|
|
61
|
+
|
|
62
|
+
**Utilities**
|
|
63
|
+
- Identity matrices and zero matrices
|
|
64
|
+
- Random vectors and matrices with configurable ranges
|
|
65
|
+
- 2D and 3D rotation matrices
|
|
66
|
+
- Diagonal matrix construction
|
|
67
|
+
|
|
68
|
+
### 🚧 In Development
|
|
69
|
+
|
|
70
|
+
- Matrix determinants and inverses
|
|
71
|
+
- Matrix decompositions (LU, QR, eigenvalue methods)
|
|
72
|
+
- Interactive visualization toolkit
|
|
73
|
+
- Animated transformations
|
|
74
|
+
- Jupyter notebook integration
|
|
75
|
+
|
|
76
|
+
### 🔮 Roadmap
|
|
77
|
+
|
|
78
|
+
- Step-by-step algorithm demonstrations
|
|
79
|
+
- Educational machine learning examples (PCA, linear regression)
|
|
80
|
+
- Physics simulations using linear operators
|
|
81
|
+
- Extended documentation with visual explanations
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install panchi
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Requirements:** Python 3.10 or higher
|
|
92
|
+
|
|
93
|
+
For the optional Manim-powered visualizations:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install panchi[manim]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
To install from source for development:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
git clone https://github.com/Gustavo-Galvao-e-Silva/panchi.git
|
|
103
|
+
cd panchi
|
|
104
|
+
pip install -e ".[dev]"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Quick Start
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from panchi.primitives import Vector, Matrix
|
|
113
|
+
from panchi.operations import dot, identity, rotation_matrix_2d
|
|
114
|
+
from math import pi
|
|
115
|
+
|
|
116
|
+
# Vector operations
|
|
117
|
+
v = Vector([3, 4])
|
|
118
|
+
magnitude = v.magnitude
|
|
119
|
+
normalized = v.normalize()
|
|
120
|
+
|
|
121
|
+
# Matrix transformations
|
|
122
|
+
rotation = rotation_matrix_2d(pi / 2)
|
|
123
|
+
point = Vector([1, 0])
|
|
124
|
+
rotated = rotation * point
|
|
125
|
+
|
|
126
|
+
# Matrix algebra
|
|
127
|
+
A = Matrix([[1, 2], [3, 4]])
|
|
128
|
+
B = Matrix([[5, 6], [7, 8]])
|
|
129
|
+
C = A * B
|
|
130
|
+
trace = C.trace
|
|
131
|
+
|
|
132
|
+
# Identity and special matrices
|
|
133
|
+
I = identity(3)
|
|
134
|
+
product = A * A.right_identity
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Use Cases
|
|
140
|
+
|
|
141
|
+
### 1. **Learning Linear Algebra**
|
|
142
|
+
Work through textbook problems with code that mirrors mathematical notation:
|
|
143
|
+
```python
|
|
144
|
+
# Verify that (AB)^T = B^T A^T
|
|
145
|
+
A = Matrix([[1, 2], [3, 4]])
|
|
146
|
+
B = Matrix([[5, 6], [7, 8]])
|
|
147
|
+
|
|
148
|
+
left_side = (A * B).T
|
|
149
|
+
right_side = B.T * A.T
|
|
150
|
+
|
|
151
|
+
assert left_side == right_side
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Contributing
|
|
157
|
+
|
|
158
|
+
panchi welcomes contributions that align with its educational mission:
|
|
159
|
+
|
|
160
|
+
1. **Clarity First** – Code should be readable by someone learning linear algebra
|
|
161
|
+
2. **Tests Required** – All new features need comprehensive pytest tests
|
|
162
|
+
3. **Descriptive Docstrings** – Follow NumPy documentation style
|
|
163
|
+
4. **Mathematical Accuracy** – Verify implementations against textbook algorithms
|
|
164
|
+
|
|
165
|
+
### How to Contribute
|
|
166
|
+
|
|
167
|
+
1. Fork the repository
|
|
168
|
+
2. Create a feature branch (`git checkout -b feature/determinant-calculation`)
|
|
169
|
+
3. Write clear, well-documented code with tests
|
|
170
|
+
4. Ensure all tests pass (`pytest tests/`)
|
|
171
|
+
5. Submit a pull request with a detailed description
|
|
172
|
+
|
|
173
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Documentation
|
|
178
|
+
|
|
179
|
+
Full documentation will be available at [panchi.readthedocs.io](https://panchi.readthedocs.io) *(coming soon)*
|
|
180
|
+
|
|
181
|
+
- **API Reference** – Complete function and class documentation
|
|
182
|
+
- **Tutorials** – Step-by-step guides for common operations
|
|
183
|
+
- **Examples** – Real-world use cases and demonstrations
|
|
184
|
+
- **Theory** – Mathematical background and explanations
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Project Status
|
|
189
|
+
|
|
190
|
+
**Current Version:** 0.1.0a1 (Alpha)
|
|
191
|
+
|
|
192
|
+
panchi is in early alpha. It is installable and the core primitives are functional, but APIs may change as the library evolves. Not recommended for production use. Feedback and contributions are very welcome.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Support
|
|
197
|
+
|
|
198
|
+
- **Issues:** Report bugs or request features via [GitHub Issues](https://github.com/Gustavo-Galvao-e-Silva/panchi/issues)
|
|
199
|
+
- **Discussions:** Ask questions in [GitHub Discussions](https://github.com/Gustavo-Galvao-e-Silva/panchi/discussions)
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
MIT License – see [LICENSE](LICENSE) for details.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Acknowledgments
|
|
210
|
+
|
|
211
|
+
panchi is inspired by educational resources that prioritize understanding:
|
|
212
|
+
- Gilbert Strang's *Introduction to Linear Algebra*
|
|
213
|
+
- 3Blue1Brown's *Essence of Linear Algebra* video series
|
|
214
|
+
- The desire to make linear algebra accessible and visual
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Final Note
|
|
219
|
+
|
|
220
|
+
panchi exists to answer a simple question:
|
|
221
|
+
|
|
222
|
+
> **"What is linear algebra actually *doing*?"**
|
|
223
|
+
|
|
224
|
+
If you've ever felt frustrated by libraries that hide the mathematics behind abstractions, or if you want to *see* transformations happen rather than just trust the output, panchi is for you.
|
|
225
|
+
|
|
226
|
+
Linear algebra is beautiful. Let's make it visible.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Panchi - A Python-native linear algebra library for learning and experimentation.
|
|
3
|
+
|
|
4
|
+
Panchi prioritizes clarity and understanding over performance, making it ideal
|
|
5
|
+
for students, educators, and anyone who wants to see how linear algebra really works.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
from panchi.primitives.vector import Vector
|
|
11
|
+
from panchi.primitives.matrix import Matrix
|
|
12
|
+
from panchi.primitives.factories import (
|
|
13
|
+
identity,
|
|
14
|
+
zero_matrix,
|
|
15
|
+
one_matrix,
|
|
16
|
+
zero_vector,
|
|
17
|
+
one_vector,
|
|
18
|
+
unit_vector,
|
|
19
|
+
diagonal,
|
|
20
|
+
random_vector,
|
|
21
|
+
random_matrix,
|
|
22
|
+
rotation_matrix_2d,
|
|
23
|
+
rotation_matrix_3d,
|
|
24
|
+
)
|
|
25
|
+
from panchi.primitives.vector_operations import (
|
|
26
|
+
dot,
|
|
27
|
+
cross,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"Vector",
|
|
32
|
+
"Matrix",
|
|
33
|
+
"identity",
|
|
34
|
+
"zero_matrix",
|
|
35
|
+
"one_matrix",
|
|
36
|
+
"zero_vector",
|
|
37
|
+
"one_vector",
|
|
38
|
+
"unit_vector",
|
|
39
|
+
"diagonal",
|
|
40
|
+
"random_vector",
|
|
41
|
+
"random_matrix",
|
|
42
|
+
"rotation_matrix_2d",
|
|
43
|
+
"rotation_matrix_3d",
|
|
44
|
+
"dot",
|
|
45
|
+
"cross",
|
|
46
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Matrix algorithms: row operations and row reductions.
|
|
3
|
+
|
|
4
|
+
This package provides the building blocks for operating on and reducing
|
|
5
|
+
matrices. Row operations represent the three elementary transformations
|
|
6
|
+
used in Gaussian elimination, and reductions apply those operations
|
|
7
|
+
systematically to bring a matrix into REF or RREF.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from panchi.algorithms.row_operations import RowSwap, RowScale, RowAdd
|
|
11
|
+
from panchi.algorithms.reductions import Reduction, ref, rref
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"RowSwap",
|
|
15
|
+
"RowScale",
|
|
16
|
+
"RowAdd",
|
|
17
|
+
"Reduction",
|
|
18
|
+
"ref",
|
|
19
|
+
"rref",
|
|
20
|
+
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from panchi.primitives.matrix import Matrix
|
|
4
|
+
from panchi.primitives.factories import identity
|
|
5
|
+
from panchi.algorithms.reductions import ref
|
|
6
|
+
from panchi.algorithms.row_operations import RowOperation, RowAdd, RowSwap
|
|
7
|
+
from panchi.algorithms.results import LUDecomposition
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _calculate_l(n: int, steps: list[RowOperation]) -> Matrix:
|
|
11
|
+
l = identity(n)
|
|
12
|
+
for step in steps:
|
|
13
|
+
if isinstance(step, RowAdd):
|
|
14
|
+
l[step.target][step.source] = -step.scalar
|
|
15
|
+
|
|
16
|
+
return l
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _calculate_p(n: int, steps: list[RowOperation]) -> Matrix:
|
|
20
|
+
p = identity(n)
|
|
21
|
+
for step in steps:
|
|
22
|
+
if isinstance(step, RowSwap):
|
|
23
|
+
p = step.apply(p)
|
|
24
|
+
|
|
25
|
+
return p
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def lu(matrix: Matrix) -> LUDecomposition:
|
|
29
|
+
matrix_ref = ref(matrix)
|
|
30
|
+
n = matrix.rows
|
|
31
|
+
steps = matrix_ref.steps
|
|
32
|
+
l = _calculate_l(n, steps)
|
|
33
|
+
u = matrix_ref.result
|
|
34
|
+
p = _calculate_p(n, steps)
|
|
35
|
+
return LUDecomposition(matrix, l, u, p, steps)
|