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
{{ message }}
Repository navigation
Matrix multiplication fails for matrix that are not Square matrix #837
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
Activity
github-actions commentedon Dec 2, 2019
Stale issue message
cclauss commentedon Dec 2, 2019
Is this fixed? Can this issue be closed?