linear-algebra01-kittithuch 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 [Kittithuch Chuaynoo]
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 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.
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.5
2
+ Name: linear-algebra01-kittithuch
3
+ Version: 0.1.0
4
+ Summary: แพ็กเกจสำหรับ linear algebra
5
+ Project-URL: Homepage, https://github.com/username/my_package
6
+ Project-URL: Documentation, https://github.com/username/my_package#readme
7
+ Project-URL: Repository, https://github.com/username/my_package.git
8
+ Project-URL: Bug Tracker, https://github.com/username/my_package/issues
9
+ Author-email: Kittithuch Chuaynoo <qmedikup@gmail.com>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: linear algebra,math
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+
25
+ # My Package
26
+
27
+ ตัวอย่าง Python Package มาตรฐาน PEP 517/621 ที่มี 2 โมดูลการทำงาน
28
+
29
+ ## การใช้งาน
30
+
31
+ ```python
32
+ import subspace_span as ss
33
+ import vector_operations as vo
34
+
35
+ # ใช้งานฟังก์ชันจาก module1
36
+ v1 = [1.0, 0.0]
37
+ v2 = [0.0, 1.0]
38
+ scalars = [2.0, -3.0]
39
+
40
+ print("1. Linear Combination (2*v1 - 3*v2) =", ss.linear_combination(scalars, [v1, v2]))
41
+ print("2. Contains Zero Vector? =", ss.is_subspace_contains_zero([v1, v2, [0, 0]]))
42
+ print("3. Are v1, v2 Linearly Independent? =", ss.is_linearly_independent_2d(v1, v2))
43
+ print("4. Do v1, v2 Span R^2? =", ss.is_spanning_r2(v1, v2))
44
+ print("5. Standard Basis for R^3 =", ss.standard_basis_r(3))
45
+
46
+ # ใช้งานฟังก์ชันจาก module2
47
+ u = [1.0, 2.0, 2.0]
48
+ v = [3.0, 0.0, -1.0]
49
+
50
+ print("1. u + v =", vo.vector_add(u, v))
51
+ print("2. 3 * u =", vo.scalar_multiply(3, u))
52
+ print("3. Magnitude of u =", vo.vector_magnitude(u))
53
+ print("4. Unit vector of u =", vo.unit_vector(u))
54
+ print("5. Is [0, 0, 0] Zero Vector? =", vo.is_zero_vector([0, 0, 0]))
@@ -0,0 +1,30 @@
1
+ # My Package
2
+
3
+ ตัวอย่าง Python Package มาตรฐาน PEP 517/621 ที่มี 2 โมดูลการทำงาน
4
+
5
+ ## การใช้งาน
6
+
7
+ ```python
8
+ import subspace_span as ss
9
+ import vector_operations as vo
10
+
11
+ # ใช้งานฟังก์ชันจาก module1
12
+ v1 = [1.0, 0.0]
13
+ v2 = [0.0, 1.0]
14
+ scalars = [2.0, -3.0]
15
+
16
+ print("1. Linear Combination (2*v1 - 3*v2) =", ss.linear_combination(scalars, [v1, v2]))
17
+ print("2. Contains Zero Vector? =", ss.is_subspace_contains_zero([v1, v2, [0, 0]]))
18
+ print("3. Are v1, v2 Linearly Independent? =", ss.is_linearly_independent_2d(v1, v2))
19
+ print("4. Do v1, v2 Span R^2? =", ss.is_spanning_r2(v1, v2))
20
+ print("5. Standard Basis for R^3 =", ss.standard_basis_r(3))
21
+
22
+ # ใช้งานฟังก์ชันจาก module2
23
+ u = [1.0, 2.0, 2.0]
24
+ v = [3.0, 0.0, -1.0]
25
+
26
+ print("1. u + v =", vo.vector_add(u, v))
27
+ print("2. 3 * u =", vo.scalar_multiply(3, u))
28
+ print("3. Magnitude of u =", vo.vector_magnitude(u))
29
+ print("4. Unit vector of u =", vo.unit_vector(u))
30
+ print("5. Is [0, 0, 0] Zero Vector? =", vo.is_zero_vector([0, 0, 0]))
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "linear-algebra01-kittithuch"
7
+ version = "0.1.0"
8
+ description = "แพ็กเกจสำหรับ linear algebra"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Kittithuch Chuaynoo", email = "qmedikup@gmail.com" }
14
+ ]
15
+ keywords = ["math", "linear algebra"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ ]
27
+ dependencies = []
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/username/my_package"
31
+ Documentation = "https://github.com/username/my_package#readme"
32
+ Repository = "https://github.com/username/my_package.git"
33
+ "Bug Tracker" = "https://github.com/username/my_package/issues"
34
+ [tool.hatch.build.targets.wheel]
35
+ packages = ["."]
@@ -0,0 +1,9 @@
1
+ """
2
+ My Package - รวมโมดูลคำนวณและจัดการข้อความ
3
+ """
4
+
5
+ from .vector_operations import vector_add, scalar_multiply, vector_magnitude, unit_vector, is_zero_vector
6
+ from .subspace_span import linear_combination, is_subspace_contains_zero, is_linearly_independent_2d, is_spanning_r2, standard_basis_r
7
+
8
+ __version__ = "0.1.0"
9
+ __all__ = ["vector_add","scalar_multiply", "vector_magnitude", "unit_vector", "is_zero_vector","linear_combination", "is_subspace_contains_zero", "is_linearly_independent_2d", "is_spanning_r2", "standard_basis_r"]
@@ -0,0 +1,66 @@
1
+ def linear_combination(scalars, vectors):
2
+
3
+ if len(scalars) != len(vectors):
4
+ print("Error: จำนวนสเกลาร์ต้องเท่ากับจำนวนเวกเตอร์")
5
+ return None
6
+
7
+ dim = len(vectors[0])
8
+ result = [0.0] * dim
9
+
10
+ for i in range(len(scalars)):
11
+ c = scalars[i]
12
+ v = vectors[i]
13
+ for j in range(dim):
14
+ result[j] = result[j] + (c * v[j])
15
+
16
+ return result
17
+
18
+ def is_subspace_contains_zero(subspace_vectors):
19
+
20
+ for i in range(len(subspace_vectors)):
21
+ v = subspace_vectors[i]
22
+
23
+ is_zero = True
24
+ for j in range(len(v)):
25
+ if v[j] != 0:
26
+ is_zero = False
27
+ break
28
+ if is_zero:
29
+ return True
30
+ return False
31
+
32
+ def is_linearly_independent_2d(u, v):
33
+
34
+ det = (u[0] * v[1]) - (u[1] * v[0])
35
+ if abs(det) > 0.000000001:
36
+ return True
37
+ else:
38
+ return False
39
+
40
+ def is_spanning_r2(v1, v2):
41
+
42
+ return is_linearly_independent_2d(v1, v2)
43
+
44
+ def standard_basis_r(n):
45
+
46
+ basis = []
47
+ for i in range(n):
48
+ e_i = [0.0] * n
49
+ e_i[i] = 1.0
50
+ basis.append(e_i)
51
+ return basis
52
+
53
+
54
+ # --- Test Script ในโมดูล ---
55
+ if __name__ == '__main__':
56
+ print("ทดสอบ")
57
+ v1 = [1.0, 0.0]
58
+ v2 = [0.0, 1.0]
59
+ scalars = [2.0, -3.0]
60
+
61
+ print("1. Linear Combination (2*v1 - 3*v2) =", linear_combination(scalars, [v1, v2]))
62
+ print("2. Contains Zero Vector? =", is_subspace_contains_zero([v1, v2, [0, 0]]))
63
+ print("3. Are v1, v2 Linearly Independent? =", is_linearly_independent_2d(v1, v2))
64
+ print("4. Do v1, v2 Span R^2? =", is_spanning_r2(v1, v2))
65
+ print("5. Standard Basis for R^3 =", standard_basis_r(3))
66
+ print("จบทดสอบ")
@@ -0,0 +1,61 @@
1
+
2
+ import math
3
+
4
+ def vector_add(u, v):
5
+
6
+ if len(u) != len(v):
7
+ print("Error: ขนาดเวกเตอร์ไม่เท่ากัน")
8
+ return None
9
+
10
+ result = []
11
+ for i in range(len(u)):
12
+ result.append(u[i] + v[i])
13
+ return result
14
+
15
+ def scalar_multiply(c, v):
16
+
17
+ result = []
18
+ for i in range(len(v)):
19
+ result.append(c * v[i])
20
+ return result
21
+
22
+ def vector_magnitude(v):
23
+
24
+ sum_sq = 0
25
+ for i in range(len(v)):
26
+ sum_sq = sum_sq + (v[i] ** 2)
27
+ return math.sqrt(sum_sq)
28
+
29
+ def unit_vector(v):
30
+
31
+ mag = vector_magnitude(v)
32
+ if mag == 0:
33
+ print("Error: ไม่สามารถหา Unit Vector ของเวกเตอร์ศูนย์ได้")
34
+ return None
35
+
36
+ result = []
37
+ for i in range(len(v)):
38
+ result.append(v[i] / mag)
39
+ return result
40
+
41
+ def is_zero_vector(v):
42
+
43
+ for i in range(len(v)):
44
+
45
+ if abs(v[i]) > 0.000000001:
46
+ return False
47
+ return True
48
+
49
+
50
+ # --- Test Script ในโมดูล ---
51
+ if __name__ == '__main__':
52
+ print("ทดสอบ")
53
+ u = [1.0, 2.0, 2.0]
54
+ v = [3.0, 0.0, -1.0]
55
+
56
+ print("1. u + v =", vector_add(u, v))
57
+ print("2. 3 * u =", scalar_multiply(3, u))
58
+ print("3. Magnitude of u =", vector_magnitude(u))
59
+ print("4. Unit vector of u =", unit_vector(u))
60
+ print("5. Is [0, 0, 0] Zero Vector? =", is_zero_vector([0, 0, 0]))
61
+ print("จบทดสอบ")