Skip to content

Commit d7a96a7

Browse files
Matrix Multiplier in Python
1 parent 7601a52 commit d7a96a7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

MatrixMultiplier.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
# taking a 3x3 matrix
4+
A = [[12, 7, 3],
5+
[4, 5, 6],
6+
[7, 8, 9]]
7+
8+
# take a 3x4 matrix
9+
B = [[5, 8, 1, 2],
10+
[6, 7, 3, 0],
11+
[4, 5, 9, 1]]
12+
13+
# result will be 3x4
14+
result = [[sum(a * b for a, b in zip(A_row, B_col))
15+
for B_col in zip(*B)]
16+
for A_row in A]
17+
#Now displaying the result
18+
for r in result:
19+
print(r)

0 commit comments

Comments
 (0)