mxcalc 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.
- mxcalc-0.1.0/LICENSE +21 -0
- mxcalc-0.1.0/PKG-INFO +36 -0
- mxcalc-0.1.0/README.md +27 -0
- mxcalc-0.1.0/pyproject.toml +15 -0
- mxcalc-0.1.0/setup.cfg +4 -0
- mxcalc-0.1.0/src/mxcalc/__init__.py +0 -0
- mxcalc-0.1.0/src/mxcalc/main.py +199 -0
- mxcalc-0.1.0/src/mxcalc.egg-info/PKG-INFO +36 -0
- mxcalc-0.1.0/src/mxcalc.egg-info/SOURCES.txt +10 -0
- mxcalc-0.1.0/src/mxcalc.egg-info/dependency_links.txt +1 -0
- mxcalc-0.1.0/src/mxcalc.egg-info/entry_points.txt +2 -0
- mxcalc-0.1.0/src/mxcalc.egg-info/top_level.txt +1 -0
mxcalc-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 dkrnr
|
|
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.
|
mxcalc-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mxcalc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A matix calculator which performs matrix operations
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# matrix calculator
|
|
11
|
+
this is a matrix calculator, where you input matrices and perform the selected operation
|
|
12
|
+
|
|
13
|
+
## operations
|
|
14
|
+
- addition (any amount of matrices)
|
|
15
|
+
- substraction (any amount of matrices)
|
|
16
|
+
- multiplication (2 matrices)
|
|
17
|
+
|
|
18
|
+
## how to use
|
|
19
|
+
- when you run `main.py` file, it will first ask you for a operation, select the operation you wish to perform
|
|
20
|
+
- then you can provide the information the systems ask about the matrices, the you will get your result at the end
|
|
21
|
+
|
|
22
|
+
## improvements to make
|
|
23
|
+
|
|
24
|
+
### make this a package
|
|
25
|
+
currently you can only use this by running `main.py` and using the helper interfaces provided by that, i feel like making it a package would give it a much better range
|
|
26
|
+
(inspired by githubs workflow suggestions)
|
|
27
|
+
|
|
28
|
+
### Add more operation
|
|
29
|
+
this operations are wayy too common. for example i want to add,
|
|
30
|
+
1. transpose
|
|
31
|
+
2. invertion(obviously)
|
|
32
|
+
3. rotation
|
|
33
|
+
and maybe flipping ? idk, we'll see
|
|
34
|
+
|
|
35
|
+
### multiple matrix calculations
|
|
36
|
+
right now only additions and substraction has unlimited amount of matrices support, idk if this is even possible but if we can do this it'll be fun
|
mxcalc-0.1.0/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# matrix calculator
|
|
2
|
+
this is a matrix calculator, where you input matrices and perform the selected operation
|
|
3
|
+
|
|
4
|
+
## operations
|
|
5
|
+
- addition (any amount of matrices)
|
|
6
|
+
- substraction (any amount of matrices)
|
|
7
|
+
- multiplication (2 matrices)
|
|
8
|
+
|
|
9
|
+
## how to use
|
|
10
|
+
- when you run `main.py` file, it will first ask you for a operation, select the operation you wish to perform
|
|
11
|
+
- then you can provide the information the systems ask about the matrices, the you will get your result at the end
|
|
12
|
+
|
|
13
|
+
## improvements to make
|
|
14
|
+
|
|
15
|
+
### make this a package
|
|
16
|
+
currently you can only use this by running `main.py` and using the helper interfaces provided by that, i feel like making it a package would give it a much better range
|
|
17
|
+
(inspired by githubs workflow suggestions)
|
|
18
|
+
|
|
19
|
+
### Add more operation
|
|
20
|
+
this operations are wayy too common. for example i want to add,
|
|
21
|
+
1. transpose
|
|
22
|
+
2. invertion(obviously)
|
|
23
|
+
3. rotation
|
|
24
|
+
and maybe flipping ? idk, we'll see
|
|
25
|
+
|
|
26
|
+
### multiple matrix calculations
|
|
27
|
+
right now only additions and substraction has unlimited amount of matrices support, idk if this is even possible but if we can do this it'll be fun
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mxcalc" # The name used for 'pip install'
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A matix calculator which performs matrix operations"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
dependencies = [
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
mxcalc = "mxcalc.main:main" # Optional: Creates a CLI command
|
mxcalc-0.1.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
def getRowsAndColumns(num):
|
|
2
|
+
"""
|
|
3
|
+
This is a fucntion to get rows and columns from user
|
|
4
|
+
|
|
5
|
+
Args:
|
|
6
|
+
num: identity number of the matrix
|
|
7
|
+
Returns:
|
|
8
|
+
values:both values as a list or -1 if error
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
row = int(input(f"Enter rows count of matrix {num} (eg :row x column):"))
|
|
13
|
+
column = int(input(f"Enter column count of matrix {num} (eg :row x column):"))
|
|
14
|
+
|
|
15
|
+
if(not (row>0 and column>0)):
|
|
16
|
+
raise ValueError
|
|
17
|
+
else:
|
|
18
|
+
return [row,column]
|
|
19
|
+
except ValueError:
|
|
20
|
+
print("\nEnter a correct integer number above 0")
|
|
21
|
+
|
|
22
|
+
return -1
|
|
23
|
+
|
|
24
|
+
def matrixMultiplicationHelper(matrices,i):
|
|
25
|
+
"""
|
|
26
|
+
This is a function that provides user with an interface to perform matrix addition
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
matrices: main list to store all matrices
|
|
30
|
+
i: number to record repeatitions
|
|
31
|
+
"""
|
|
32
|
+
i = 1
|
|
33
|
+
while i>0:
|
|
34
|
+
print(f"\nEnter details for Matrix {i}")
|
|
35
|
+
print("=====================")
|
|
36
|
+
|
|
37
|
+
values = getRowsAndColumns(i)
|
|
38
|
+
if(values == -1):
|
|
39
|
+
continue
|
|
40
|
+
|
|
41
|
+
matrix = getMatrix(values[0],values[1])
|
|
42
|
+
if(matrix==-1):
|
|
43
|
+
continue
|
|
44
|
+
|
|
45
|
+
matrices.append(matrix)
|
|
46
|
+
displayMatrix(matrix,False)
|
|
47
|
+
i+=1
|
|
48
|
+
if(i>2):
|
|
49
|
+
break
|
|
50
|
+
if(i>2 and input("\nAdd another Matrix to calculation (y if yes):").lower() != "y"):
|
|
51
|
+
break
|
|
52
|
+
|
|
53
|
+
finalMatrix = matrixMultiplication(matrices)
|
|
54
|
+
displayMatrix(finalMatrix,True)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def matrixAddSubHelper(matrices,oprt,i):
|
|
58
|
+
"""
|
|
59
|
+
This is a function that provides user with an interface to perform matrix addition
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
matrices: main list to store all matrices
|
|
63
|
+
oprt: the operator being used for calculation
|
|
64
|
+
i: number to record repeatitions
|
|
65
|
+
"""
|
|
66
|
+
values = getRowsAndColumns(i)
|
|
67
|
+
if(values != -1):
|
|
68
|
+
while i>0:
|
|
69
|
+
print(f"\nEnter details for Matrix {i}")
|
|
70
|
+
print("=====================")
|
|
71
|
+
|
|
72
|
+
matrix = getMatrix(values[0],values[1])
|
|
73
|
+
if(matrix==-1):
|
|
74
|
+
continue
|
|
75
|
+
|
|
76
|
+
matrices.append(matrix)
|
|
77
|
+
displayMatrix(matrix,False)
|
|
78
|
+
i+=1
|
|
79
|
+
if(i>2 and input("\nAdd another Matrix to calculation (y if yes):").lower() != "y"):
|
|
80
|
+
break
|
|
81
|
+
|
|
82
|
+
finalMatrix = matrixAddSub(matrices,oprt)
|
|
83
|
+
displayMatrix(finalMatrix,True)
|
|
84
|
+
|
|
85
|
+
def getMatrix(rows,columns):
|
|
86
|
+
"""
|
|
87
|
+
This is a function to get matrix values according to the rows anc columns count
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
rows: the row count of the matrix
|
|
91
|
+
columns: the column count of the matrix
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
matrix: the matrix with all of the values
|
|
95
|
+
"""
|
|
96
|
+
matrix = []
|
|
97
|
+
print()
|
|
98
|
+
for j in range(rows):
|
|
99
|
+
matrix.append([])
|
|
100
|
+
for k in range(columns):
|
|
101
|
+
try:
|
|
102
|
+
value = int(input(f"Enter values for row {j+1}, column {k+1}:"))
|
|
103
|
+
matrix[j].append(value)
|
|
104
|
+
except ValueError as e:
|
|
105
|
+
print("Error:","Enter a correct Integer value")
|
|
106
|
+
return -1
|
|
107
|
+
return matrix
|
|
108
|
+
|
|
109
|
+
def displayMatrix(matrix,isFinal):
|
|
110
|
+
"""
|
|
111
|
+
This is a function to display the given matrix
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
matrices: matrix to be operated on as a list
|
|
115
|
+
isFinal: if needs to be displayed as the final matrix
|
|
116
|
+
"""
|
|
117
|
+
print()
|
|
118
|
+
if (isFinal):
|
|
119
|
+
print("The Final Matrix")
|
|
120
|
+
print("=================")
|
|
121
|
+
for l in range (len(matrix)):
|
|
122
|
+
print(matrix[l])
|
|
123
|
+
|
|
124
|
+
def matrixAddSub(matrices,oprt):
|
|
125
|
+
"""
|
|
126
|
+
This is a function to add or substract the given array of matrices
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
matrices: matrices to be operated on as a list
|
|
130
|
+
opr : which operation (add or substract) to be performed, as "-" or "+"
|
|
131
|
+
|
|
132
|
+
returns:
|
|
133
|
+
result: Resulting matrix
|
|
134
|
+
"""
|
|
135
|
+
finalMatrix = []
|
|
136
|
+
for j in range(len(matrices[0])):
|
|
137
|
+
finalMatrix.append([])
|
|
138
|
+
for k in range(len(matrices[0][0])):
|
|
139
|
+
sum = 0
|
|
140
|
+
for m in range(len(matrices)):
|
|
141
|
+
if(oprt == "+"):
|
|
142
|
+
sum += matrices[m][j][k]
|
|
143
|
+
else:
|
|
144
|
+
if(m>0):
|
|
145
|
+
sum -= matrices[m][j][k]
|
|
146
|
+
else:
|
|
147
|
+
sum += matrices[m][j][k]
|
|
148
|
+
finalMatrix[j].append(sum)
|
|
149
|
+
return finalMatrix
|
|
150
|
+
|
|
151
|
+
def matrixMultiplication(matrices):
|
|
152
|
+
"""
|
|
153
|
+
This is a function to multiply the given array of matrices
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
matrices: matrices to be multiplied as a list
|
|
157
|
+
|
|
158
|
+
returns:
|
|
159
|
+
result: Resulting multiplied matrix
|
|
160
|
+
"""
|
|
161
|
+
finalMatrix = []
|
|
162
|
+
if len(matrices[0][0])!=len(matrices[1]):
|
|
163
|
+
print("Cannot Multiply")
|
|
164
|
+
finalMatrix = -1
|
|
165
|
+
else:
|
|
166
|
+
for rw in range(len(matrices[0])):
|
|
167
|
+
finalMatrix.append([])
|
|
168
|
+
for clmn in range(len(matrices[1][0])):
|
|
169
|
+
sum = 0
|
|
170
|
+
for val in range(len(matrices[0][0])):
|
|
171
|
+
sum += matrices[0][rw][val]*matrices[1][val][clmn]
|
|
172
|
+
finalMatrix[rw].append(sum)
|
|
173
|
+
|
|
174
|
+
return finalMatrix
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def main():
|
|
178
|
+
while True:
|
|
179
|
+
matrices = []
|
|
180
|
+
i = 1
|
|
181
|
+
print("Matrice Calculator")
|
|
182
|
+
print("==================\n")
|
|
183
|
+
|
|
184
|
+
oprt = input("Choose an operation (+,-,*):").strip()
|
|
185
|
+
match oprt:
|
|
186
|
+
case "*":
|
|
187
|
+
matrixMultiplicationHelper(matrices,i)
|
|
188
|
+
case "+"|"-":
|
|
189
|
+
matrixAddSubHelper(matrices,oprt,i)
|
|
190
|
+
case _:
|
|
191
|
+
print("Invalid Operator")
|
|
192
|
+
|
|
193
|
+
if(input("\nRepeat this process? (y if yes):").lower() != "y"):
|
|
194
|
+
print("\nExiting system...")
|
|
195
|
+
break
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if __name__ == "__main__":
|
|
199
|
+
main()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mxcalc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A matix calculator which performs matrix operations
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# matrix calculator
|
|
11
|
+
this is a matrix calculator, where you input matrices and perform the selected operation
|
|
12
|
+
|
|
13
|
+
## operations
|
|
14
|
+
- addition (any amount of matrices)
|
|
15
|
+
- substraction (any amount of matrices)
|
|
16
|
+
- multiplication (2 matrices)
|
|
17
|
+
|
|
18
|
+
## how to use
|
|
19
|
+
- when you run `main.py` file, it will first ask you for a operation, select the operation you wish to perform
|
|
20
|
+
- then you can provide the information the systems ask about the matrices, the you will get your result at the end
|
|
21
|
+
|
|
22
|
+
## improvements to make
|
|
23
|
+
|
|
24
|
+
### make this a package
|
|
25
|
+
currently you can only use this by running `main.py` and using the helper interfaces provided by that, i feel like making it a package would give it a much better range
|
|
26
|
+
(inspired by githubs workflow suggestions)
|
|
27
|
+
|
|
28
|
+
### Add more operation
|
|
29
|
+
this operations are wayy too common. for example i want to add,
|
|
30
|
+
1. transpose
|
|
31
|
+
2. invertion(obviously)
|
|
32
|
+
3. rotation
|
|
33
|
+
and maybe flipping ? idk, we'll see
|
|
34
|
+
|
|
35
|
+
### multiple matrix calculations
|
|
36
|
+
right now only additions and substraction has unlimited amount of matrices support, idk if this is even possible but if we can do this it'll be fun
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/mxcalc/__init__.py
|
|
5
|
+
src/mxcalc/main.py
|
|
6
|
+
src/mxcalc.egg-info/PKG-INFO
|
|
7
|
+
src/mxcalc.egg-info/SOURCES.txt
|
|
8
|
+
src/mxcalc.egg-info/dependency_links.txt
|
|
9
|
+
src/mxcalc.egg-info/entry_points.txt
|
|
10
|
+
src/mxcalc.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mxcalc
|