matrealm 0.1.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,2 @@
1
+ global-exclude matrealm/item/encryption.py
2
+ global-exclude matrealm/item/eachmouth.md
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.1
2
+ Name: matrealm
3
+ Version: 0.1.0
4
+ Summary: 矩阵域计算工具 - Domain-Aware Matrix Computation
5
+ Author-email: Matrealm Project <dev@matrealm.io>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/matrealm/matrealm
8
+ Project-URL: Documentation, https://matrealm.readthedocs.io
9
+ Project-URL: Repository, https://github.com/matrealm/matrealm
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: numpy>=1.24.0
21
+
22
+ # Matrealm — Matrix Realm
23
+
24
+ **Domain-Aware Matrix Computation for Python**
25
+
26
+ [![PyPI version](https://img.shields.io/badge/pypi-v0.1.0-blue)](https://pypi.org/project/matrealm/)
27
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue)](https://python.org)
28
+ [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
29
+ [![Status](https://img.shields.io/badge/status-alpha-orange)]()
30
+
31
+ ---
32
+
33
+ Matrealm is a domain-aware matrix computation library that brings algebraic field information directly into matrix operations. Every matrix is bound to its algebraic domain — **ℝ** (real), **ℂ** (complex), **GF(p)** (finite field), or **ℍ** (quaternion) — and all operations respect the rules of that domain.
34
+
35
+ > **Why domains matter:** `1 + 1 = 2` in ℝ, but `1 + 1 = 0` in GF(2). Matrealm keeps you mathematically honest.
36
+
37
+ ---
38
+
39
+ ## Features
40
+
41
+ | Feature | Description |
42
+ |---|---|
43
+ | 🧠 **Domain-Aware Matrices** | Every matrix tracks its algebraic domain automatically |
44
+ | 🔢 **Multi-Domain Support** | ℝ · ℂ · GF(p) · ℍ — all first-class citizens |
45
+ | 🔄 **Domain Transforms** | Seamlessly convert between domains (ℝ→ℂ, ℝ→GF(p), etc.) |
46
+ | 🛡️ **Domain Safety** | Prevents cross-domain operations at runtime |
47
+ | ⚡ **NumPy Backend** | Performance of NumPy, semantics of abstract algebra |
48
+ | 🖥️ **Built-in CLI** | Full command-line interface, no code required |
49
+
50
+ ---
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install matrealm
56
+ ```
57
+
58
+ Or from source:
59
+
60
+ ```bash
61
+ git clone https://github.com/matrealm/matrealm.git
62
+ cd matrealm
63
+ pip install -e .
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Quick Start
69
+
70
+ ### Python API
71
+
72
+ ```python
73
+ from matrealm import Matrix, Domain, MatrixOperations, DomainTransform
74
+
75
+ # Create 3×3 matrices over ℝ
76
+ A = Matrix.random(3, 3, domain=Domain.real())
77
+ B = Matrix.random(3, 3, domain=Domain.real())
78
+
79
+ # Matrix multiplication (domain-safe)
80
+ C = MatrixOperations.multiply(A, B)
81
+
82
+ # Domain transform: ℝ → GF(7)
83
+ A_finite = DomainTransform.to_finite(A, p=7)
84
+ print(A_finite)
85
+
86
+ # Determinant
87
+ det = MatrixOperations.determinant(A)
88
+ print(f"det(A) = {det:.4f}")
89
+
90
+ # Eigenvalues
91
+ eigs = MatrixOperations.eigenvalues(A)
92
+ print(f"λ(A) = {eigs}")
93
+ ```
94
+
95
+ ### Finite Field Example
96
+
97
+ ```python
98
+ from matrealm import Matrix, Domain, MatrixOperations
99
+
100
+ # GF(2) — the simplest finite field
101
+ A = Matrix([[1, 0], [1, 1]], domain=Domain.finite(2))
102
+ B = Matrix([[0, 1], [1, 0]], domain=Domain.finite(2))
103
+
104
+ # In GF(2): 1 + 1 = 0
105
+ C = MatrixOperations.add(A, B)
106
+ print(C)
107
+ # [[1, 1],
108
+ # [0, 1]] ← note: 1+1 became 0
109
+ ```
110
+
111
+ ---
112
+
113
+ ## CLI
114
+
115
+ ```bash
116
+ # Create a 3×3 random matrix over ℝ
117
+ matrealm create 3 3 --type random
118
+
119
+ # Create a 4×4 identity matrix over GF(11)
120
+ matrealm create 4 4 --type identity --domain finite --mod 11
121
+
122
+ # Transform a matrix from ℝ to GF(7)
123
+ matrealm transform --from-domain real --to-domain finite --mod 7
124
+
125
+ # Compute determinant of a 4×4 random matrix
126
+ matrealm op det --size 4
127
+
128
+ # Multiply two 3×3 random matrices
129
+ matrealm op mul --size 3
130
+
131
+ # Show matrix info
132
+ matrealm info --rows 5 --cols 5
133
+ ```
134
+
135
+ ---
136
+
137
+ ## API Overview
138
+
139
+ ### Domains
140
+
141
+ ```python
142
+ Domain.real() # ℝ
143
+ Domain.complex() # ℂ
144
+ Domain.finite(p=7) # GF(7)
145
+ Domain.quaternion() # ℍ
146
+ ```
147
+
148
+ ### Matrix Factory Methods
149
+
150
+ | Method | Description |
151
+ |---|---|
152
+ | `Matrix.zeros(m, n)` | Zero matrix |
153
+ | `Matrix.ones(m, n)` | All-ones matrix |
154
+ | `Matrix.identity(n)` | Identity matrix |
155
+ | `Matrix.random(m, n)` | Random entries ~ N(0,1) |
156
+
157
+ ### Operations
158
+
159
+ | Function | Symbol | Description |
160
+ |---|---|---|
161
+ | `MatrixOperations.add(A, B)` | A + B | Addition |
162
+ | `MatrixOperations.subtract(A, B)` | A − B | Subtraction |
163
+ | `MatrixOperations.multiply(A, B)` | A · B | Matrix product |
164
+ | `MatrixOperations.transpose(A)` | Aᵀ | Transpose |
165
+ | `MatrixOperations.trace(A)` | tr(A) | Trace |
166
+ | `MatrixOperations.determinant(A)` | det(A) | Determinant |
167
+ | `MatrixOperations.inverse(A)` | A⁻¹ | Inverse |
168
+ | `MatrixOperations.eigenvalues(A)` | λ(A) | Eigenvalues |
169
+
170
+ ### Domain Transforms
171
+
172
+ | Transform | Description |
173
+ |---|---|
174
+ | `DomainTransform.to_complex(M)` | ℝ → ℂ |
175
+ | `DomainTransform.to_real(M)` | ℂ → ℝ (drops imaginary part) |
176
+ | `DomainTransform.to_finite(M, p)` | Any → GF(p) (mod p) |
177
+ | `DomainTransform.to_quaternion(M)` | ℝ → ℍ |
178
+
179
+ ---
180
+
181
+ ## Project Structure
182
+
183
+ ```
184
+ matrealm/
185
+ ├── matrealm/ # Library source
186
+ │ ├── __init__.py # Public API exports
187
+ │ ├── cli/
188
+ │ │ └── main.py # CLI entry point
189
+ │ └── core/
190
+ │ ├── domain.py # Domain types & definitions
191
+ │ ├── matrix.py # Matrix data structure
192
+ │ ├── operations.py # Domain-safe arithmetic
193
+ │ └── transform.py # Inter-domain conversion
194
+ ├── tests/
195
+ │ └── test_core.py # Unit tests
196
+ ├── examples/
197
+ │ └── demo.py # Usage examples
198
+ ├── docs/
199
+ │ └── guide.md # User guide
200
+ ├── README.md
201
+ ├── CONTRIBUTING.md
202
+ └── pyproject.toml
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Documentation
208
+
209
+ Full documentation: [https://matrealm.readthedocs.io](https://matrealm.readthedocs.io)
210
+
211
+ - [User Guide](docs/guide.md)
212
+ - [API Reference](https://matrealm.readthedocs.io/en/latest/api/)
213
+ - [Contributing Guide](CONTRIBUTING.md)
214
+
215
+ ---
216
+
217
+ ## Development
218
+
219
+ ```bash
220
+ git clone https://github.com/matrealm/matrealm.git
221
+ cd matrealm
222
+ python -m venv venv
223
+ source venv/bin/activate # Windows: venv\Scripts\activate
224
+ pip install -e ".[dev]"
225
+ pytest tests/ -v
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Roadmap
231
+
232
+ - [x] Core matrix structure with domain binding
233
+ - [x] ℝ, ℂ, GF(p) domain support
234
+ - [x] Domain-safe arithmetic operations
235
+ - [x] CLI interface
236
+ - [ ] GF(p) determinant & inverse
237
+ - [ ] Eigenvalue decomposition
238
+ - [ ] SVD & QR factorization
239
+ - [ ] GPU backend (CUDA)
240
+ - [ ] Custom user-defined domains
241
+
242
+ ---
243
+
244
+ ## License
245
+
246
+ MIT License — see [LICENSE](LICENSE) for details.
247
+
248
+ ---
249
+
250
+ <p align="center">
251
+ <sub>Built with numpy, powered by abstract algebra.</sub>
252
+ </p>
@@ -0,0 +1,231 @@
1
+ # Matrealm — Matrix Realm
2
+
3
+ **Domain-Aware Matrix Computation for Python**
4
+
5
+ [![PyPI version](https://img.shields.io/badge/pypi-v0.1.0-blue)](https://pypi.org/project/matrealm/)
6
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue)](https://python.org)
7
+ [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
8
+ [![Status](https://img.shields.io/badge/status-alpha-orange)]()
9
+
10
+ ---
11
+
12
+ Matrealm is a domain-aware matrix computation library that brings algebraic field information directly into matrix operations. Every matrix is bound to its algebraic domain — **ℝ** (real), **ℂ** (complex), **GF(p)** (finite field), or **ℍ** (quaternion) — and all operations respect the rules of that domain.
13
+
14
+ > **Why domains matter:** `1 + 1 = 2` in ℝ, but `1 + 1 = 0` in GF(2). Matrealm keeps you mathematically honest.
15
+
16
+ ---
17
+
18
+ ## Features
19
+
20
+ | Feature | Description |
21
+ |---|---|
22
+ | 🧠 **Domain-Aware Matrices** | Every matrix tracks its algebraic domain automatically |
23
+ | 🔢 **Multi-Domain Support** | ℝ · ℂ · GF(p) · ℍ — all first-class citizens |
24
+ | 🔄 **Domain Transforms** | Seamlessly convert between domains (ℝ→ℂ, ℝ→GF(p), etc.) |
25
+ | 🛡️ **Domain Safety** | Prevents cross-domain operations at runtime |
26
+ | ⚡ **NumPy Backend** | Performance of NumPy, semantics of abstract algebra |
27
+ | 🖥️ **Built-in CLI** | Full command-line interface, no code required |
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install matrealm
35
+ ```
36
+
37
+ Or from source:
38
+
39
+ ```bash
40
+ git clone https://github.com/matrealm/matrealm.git
41
+ cd matrealm
42
+ pip install -e .
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Quick Start
48
+
49
+ ### Python API
50
+
51
+ ```python
52
+ from matrealm import Matrix, Domain, MatrixOperations, DomainTransform
53
+
54
+ # Create 3×3 matrices over ℝ
55
+ A = Matrix.random(3, 3, domain=Domain.real())
56
+ B = Matrix.random(3, 3, domain=Domain.real())
57
+
58
+ # Matrix multiplication (domain-safe)
59
+ C = MatrixOperations.multiply(A, B)
60
+
61
+ # Domain transform: ℝ → GF(7)
62
+ A_finite = DomainTransform.to_finite(A, p=7)
63
+ print(A_finite)
64
+
65
+ # Determinant
66
+ det = MatrixOperations.determinant(A)
67
+ print(f"det(A) = {det:.4f}")
68
+
69
+ # Eigenvalues
70
+ eigs = MatrixOperations.eigenvalues(A)
71
+ print(f"λ(A) = {eigs}")
72
+ ```
73
+
74
+ ### Finite Field Example
75
+
76
+ ```python
77
+ from matrealm import Matrix, Domain, MatrixOperations
78
+
79
+ # GF(2) — the simplest finite field
80
+ A = Matrix([[1, 0], [1, 1]], domain=Domain.finite(2))
81
+ B = Matrix([[0, 1], [1, 0]], domain=Domain.finite(2))
82
+
83
+ # In GF(2): 1 + 1 = 0
84
+ C = MatrixOperations.add(A, B)
85
+ print(C)
86
+ # [[1, 1],
87
+ # [0, 1]] ← note: 1+1 became 0
88
+ ```
89
+
90
+ ---
91
+
92
+ ## CLI
93
+
94
+ ```bash
95
+ # Create a 3×3 random matrix over ℝ
96
+ matrealm create 3 3 --type random
97
+
98
+ # Create a 4×4 identity matrix over GF(11)
99
+ matrealm create 4 4 --type identity --domain finite --mod 11
100
+
101
+ # Transform a matrix from ℝ to GF(7)
102
+ matrealm transform --from-domain real --to-domain finite --mod 7
103
+
104
+ # Compute determinant of a 4×4 random matrix
105
+ matrealm op det --size 4
106
+
107
+ # Multiply two 3×3 random matrices
108
+ matrealm op mul --size 3
109
+
110
+ # Show matrix info
111
+ matrealm info --rows 5 --cols 5
112
+ ```
113
+
114
+ ---
115
+
116
+ ## API Overview
117
+
118
+ ### Domains
119
+
120
+ ```python
121
+ Domain.real() # ℝ
122
+ Domain.complex() # ℂ
123
+ Domain.finite(p=7) # GF(7)
124
+ Domain.quaternion() # ℍ
125
+ ```
126
+
127
+ ### Matrix Factory Methods
128
+
129
+ | Method | Description |
130
+ |---|---|
131
+ | `Matrix.zeros(m, n)` | Zero matrix |
132
+ | `Matrix.ones(m, n)` | All-ones matrix |
133
+ | `Matrix.identity(n)` | Identity matrix |
134
+ | `Matrix.random(m, n)` | Random entries ~ N(0,1) |
135
+
136
+ ### Operations
137
+
138
+ | Function | Symbol | Description |
139
+ |---|---|---|
140
+ | `MatrixOperations.add(A, B)` | A + B | Addition |
141
+ | `MatrixOperations.subtract(A, B)` | A − B | Subtraction |
142
+ | `MatrixOperations.multiply(A, B)` | A · B | Matrix product |
143
+ | `MatrixOperations.transpose(A)` | Aᵀ | Transpose |
144
+ | `MatrixOperations.trace(A)` | tr(A) | Trace |
145
+ | `MatrixOperations.determinant(A)` | det(A) | Determinant |
146
+ | `MatrixOperations.inverse(A)` | A⁻¹ | Inverse |
147
+ | `MatrixOperations.eigenvalues(A)` | λ(A) | Eigenvalues |
148
+
149
+ ### Domain Transforms
150
+
151
+ | Transform | Description |
152
+ |---|---|
153
+ | `DomainTransform.to_complex(M)` | ℝ → ℂ |
154
+ | `DomainTransform.to_real(M)` | ℂ → ℝ (drops imaginary part) |
155
+ | `DomainTransform.to_finite(M, p)` | Any → GF(p) (mod p) |
156
+ | `DomainTransform.to_quaternion(M)` | ℝ → ℍ |
157
+
158
+ ---
159
+
160
+ ## Project Structure
161
+
162
+ ```
163
+ matrealm/
164
+ ├── matrealm/ # Library source
165
+ │ ├── __init__.py # Public API exports
166
+ │ ├── cli/
167
+ │ │ └── main.py # CLI entry point
168
+ │ └── core/
169
+ │ ├── domain.py # Domain types & definitions
170
+ │ ├── matrix.py # Matrix data structure
171
+ │ ├── operations.py # Domain-safe arithmetic
172
+ │ └── transform.py # Inter-domain conversion
173
+ ├── tests/
174
+ │ └── test_core.py # Unit tests
175
+ ├── examples/
176
+ │ └── demo.py # Usage examples
177
+ ├── docs/
178
+ │ └── guide.md # User guide
179
+ ├── README.md
180
+ ├── CONTRIBUTING.md
181
+ └── pyproject.toml
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Documentation
187
+
188
+ Full documentation: [https://matrealm.readthedocs.io](https://matrealm.readthedocs.io)
189
+
190
+ - [User Guide](docs/guide.md)
191
+ - [API Reference](https://matrealm.readthedocs.io/en/latest/api/)
192
+ - [Contributing Guide](CONTRIBUTING.md)
193
+
194
+ ---
195
+
196
+ ## Development
197
+
198
+ ```bash
199
+ git clone https://github.com/matrealm/matrealm.git
200
+ cd matrealm
201
+ python -m venv venv
202
+ source venv/bin/activate # Windows: venv\Scripts\activate
203
+ pip install -e ".[dev]"
204
+ pytest tests/ -v
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Roadmap
210
+
211
+ - [x] Core matrix structure with domain binding
212
+ - [x] ℝ, ℂ, GF(p) domain support
213
+ - [x] Domain-safe arithmetic operations
214
+ - [x] CLI interface
215
+ - [ ] GF(p) determinant & inverse
216
+ - [ ] Eigenvalue decomposition
217
+ - [ ] SVD & QR factorization
218
+ - [ ] GPU backend (CUDA)
219
+ - [ ] Custom user-defined domains
220
+
221
+ ---
222
+
223
+ ## License
224
+
225
+ MIT License — see [LICENSE](LICENSE) for details.
226
+
227
+ ---
228
+
229
+ <p align="center">
230
+ <sub>Built with numpy, powered by abstract algebra.</sub>
231
+ </p>
@@ -0,0 +1,41 @@
1
+ # Contributing to Matrealm
2
+
3
+ Thank you for your interest in Matrealm!
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/matrealm/matrealm.git
9
+ cd matrealm
10
+ python -m venv venv
11
+ source venv/bin/activate # Windows: venv\Scripts\activate
12
+ pip install -e ".[dev]"
13
+ ```
14
+
15
+ ## Running Tests
16
+
17
+ ```bash
18
+ pytest tests/ -v
19
+ ```
20
+
21
+ ## Code Style
22
+
23
+ - PEP 8 compliant
24
+ - Full type annotations
25
+ - Google-style docstrings
26
+
27
+ ## Pull Request Process
28
+
29
+ 1. Fork the repository
30
+ 2. Create a feature branch: `git checkout -b feat/your-feature`
31
+ 3. Commit your changes: `git commit -m "feat: add ..."`
32
+ 4. Push: `git push origin feat/your-feature`
33
+ 5. Open a Pull Request
34
+
35
+ ## Versioning
36
+
37
+ This project follows [SemVer](https://semver.org/):
38
+
39
+ - MAJOR: incompatible API changes
40
+ - MINOR: backward-compatible feature additions
41
+ - PATCH: backward-compatible bug fixes