strang 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.
strang-0.1.0/PKG-INFO ADDED
@@ -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
strang-0.1.0/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # strang
2
+
3
+ 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.
4
+
5
+ # Installation
6
+
7
+ pip:
8
+ ```bash
9
+ pip install strang
10
+ ```
11
+
12
+ uv:
13
+ ```bash
14
+ uv add strang
15
+ ```
16
+
17
+ # License
18
+
19
+ this project is licensed under the MIT License - see the LICENSE file for details
20
+
21
+ ---
22
+
23
+ All by quandela
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "strang"
3
+ version = "0.1.0"
4
+ description = "A linear algebra library with a focus on lengthy operations being made simple"
5
+ readme = "README.md"
6
+ description-content-type = "text/markdown"
7
+ license = "MIT"
8
+ keywords = [
9
+ "math",
10
+ "linear-algebra",
11
+ ]
12
+ requires-python = ">=3.12"
13
+ dependencies = ["numpy>=2.5.3"]
14
+
15
+ [[project.authors]]
16
+ name = "quandelaa"
17
+ email = "sergiotobamasilalahi@gmail.com"
18
+
19
+ [project.urls]
20
+ Repository = "https://github.com/quandelaa/strang"
21
+
22
+ [build-system]
23
+ requires = ["uv_build>=0.12.10,<0.13.0"]
24
+ build-backend = "uv_build"
25
+
26
+ [dependency-groups]
27
+ dev = ["pytest>=9.1.1"]
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "strang"
3
+ version = "0.1.0"
4
+ description = "A linear algebra library with a focus on lengthy operations being made simple"
5
+ readme = "README.md"
6
+ description-content-type = "text/markdown"
7
+ license = "MIT"
8
+ authors = [
9
+ { name = "quandelaa", email = "sergiotobamasilalahi@gmail.com" }
10
+ ]
11
+ keywords = ["math", "linear-algebra"]
12
+ requires-python = ">=3.12"
13
+ dependencies = [
14
+ "numpy>=2.5.3",
15
+ ]
16
+
17
+ [project.urls]
18
+ Repository = "https://github.com/quandelaa/strang"
19
+
20
+ [build-system]
21
+ requires = ["uv_build>=0.12.10,<0.13.0"]
22
+ build-backend = "uv_build"
23
+
24
+ [dependency-groups]
25
+ dev = [
26
+ "pytest>=9.1.1",
27
+ ]
@@ -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
File without changes