Python Program for Matrix Multiplication
import numpy as np
import math
#------Python Program for Matix Multiplication-----#
# take a 2x3 matrix
X = [ [8, 6, 3],
[6, 8, 4]]
# take a 3x3 matrix
Y = [ [7, 8, 1],
[12, 9, 3],
[2, 4, 5]]
result = [[0, 0, 0],
[0, 0, 0]]
for i in range(len(X)):
for j in range(len(Y[0])):
for k in range(len(Y)):
result[i][j] += X[i][k] * Y[k][j]
for r in result:
print(r)
OUTPUT
>>>
=============== RESTART: D:/Desktop/Python(TUT)/MatrixMulti.py ===============
[134, 130, 41]
[146, 136, 50]
>>>