-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix.py
More file actions
34 lines (26 loc) · 735 Bytes
/
matrix.py
File metadata and controls
34 lines (26 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
def calculateMatrixMultiplication(A:np.array, B:np.array) -> np.array:
rowsA = A.shape[0]
colsA = A.shape[1]
rowsB = B.shape[0]
colsB = B.shape[1]
C = np.zeros((rowsA, colsB), dtype=int)
for r in range(rowsA):
for c in range(colsB):
result = 0
for k in range(colsA):
result += A[r][k] * B[k][c]
C[r][c] = result
print(result)
return C
def main() -> None:
A = np.array([[3, -1, -2],
[2, 4, -2]
])
B = np.array([[2, -2],
[3, 1],
[-2, 4]
])
calculateMatrixMultiplication(A, B)
print("Done")
main()