strang 0.1.0__py3-none-any.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.
strang/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from strang.decomposition import lu
@@ -0,0 +1,35 @@
1
+ import numpy as np
2
+
3
+ def lu(A: np.ndarray):
4
+ """
5
+ Calculates LU Decomposition of the given array. Returns P, L, U
6
+ """
7
+
8
+ if type(A) != np.ndarray:
9
+ raise TypeError("array needs to be a numpy array")
10
+
11
+ A = A.astype(float).copy()
12
+
13
+ rows, cols = A.shape
14
+ if rows != cols:
15
+ raise Exception("matrix needs to be square")
16
+
17
+ L = np.identity(rows)
18
+ P = np.identity(rows)
19
+
20
+ for k in range(rows):
21
+ if np.isclose(A[k, k], 0, atol=1e-12):
22
+ for i in range(k+1, rows):
23
+ if not np.isclose(A[i, k], 0, atol=1e-12):
24
+ A[[k, i]] = A[[i, k]]
25
+ P[[k, i]] = P[[i, k]]
26
+ L[[k, i], :k] = L[[i, k], :k]
27
+
28
+ for i in range(k+1, rows):
29
+ mul = A[i, k] / A[k, k]
30
+ new_row = A[i] - (A[k] * mul)
31
+
32
+ L[i, k] = mul
33
+ A[i] = new_row
34
+
35
+ return P, L, A
strang/py.typed ADDED
File without changes
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.4
2
+ Name: strang
3
+ Version: 0.1.0
4
+ Summary: A linear algebra library with a focus on lengthy operations being made simple
5
+ Keywords: math,linear-algebra
6
+ Author: quandelaa
7
+ Author-email: quandelaa <sergiotobamasilalahi@gmail.com>
8
+ License-Expression: MIT
9
+ Requires-Dist: numpy>=2.5.3
10
+ Requires-Python: >=3.12
11
+ Project-URL: Repository, https://github.com/quandelaa/strang
12
+ Description-Content-Type: text/markdown
13
+
14
+ # strang
15
+
16
+ A linear algebra library with a focus on lengthy operations being made simple. The name 'strang' is taken directly from Gilbert Strang because he's thaught me lots of linear algebra.
17
+
18
+ # Installation
19
+
20
+ pip:
21
+ ```bash
22
+ pip install strang
23
+ ```
24
+
25
+ uv:
26
+ ```bash
27
+ uv add strang
28
+ ```
29
+
30
+ # License
31
+
32
+ this project is licensed under the MIT License - see the LICENSE file for details
33
+
34
+ ---
35
+
36
+ All by quandela
@@ -0,0 +1,6 @@
1
+ strang/__init__.py,sha256=gX6JpSSAasXphszglq5JYHasbqlJR1KdT5P150QrO3A,36
2
+ strang/decomposition.py,sha256=jJwUwebMtMz4eTAv6r55o5jOCdmu-X9V_g_E0B3_ZFs,896
3
+ strang/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ strang-0.1.0.dist-info/WHEEL,sha256=Kot-FOXwz2no6rGIg4et79Z7m6vcKPAXr2Y6fTFpZuI,81
5
+ strang-0.1.0.dist-info/METADATA,sha256=stTzgGveqsMVic7XViC-ALzlHxOK_I-v5ey6OHELrp0,813
6
+ strang-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.12.10
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any