You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently The Matrix Multiplication function can multiply only square matrices
current code is def multiply(matrix_a, matrix_b): matrix_c = [] n = len(matrix_a) for i in range(n): list_1 = [] for j in range(n): val = 0 for k in range(n): val = val + matrix_a[i][k] * matrix_b[k][j] list_1.append(val) matrix_c.append(list_1) return matrix_c
This could be changed to
def multiply(matrix_a, matrix_b):
matrix_c = []
n = len(matrix_a) #no of rows in Mat_a
m = len(matrix_a[0]) #no of cols in Mat_a
l = len(matrix_b[0]) #no of cols in Mat_b
for i in range(n):
list_1 = []
for j in range(l):
val = 0
for k in range(m):
val = val + matrix_a[i][k] * matrix_b[k][j]
list_1.append(val)
matrix_c.append(list_1)
return matrix_c
The text was updated successfully, but these errors were encountered:
Currently The Matrix Multiplication function can multiply only square matrices
current code is
def multiply(matrix_a, matrix_b): matrix_c = [] n = len(matrix_a) for i in range(n): list_1 = [] for j in range(n): val = 0 for k in range(n): val = val + matrix_a[i][k] * matrix_b[k][j] list_1.append(val) matrix_c.append(list_1) return matrix_c
The text was updated successfully, but these errors were encountered: