Question: Please design a function to calculate the matrix multiplication PYTHON CODE: you need to design a matrix multiplication function MaxProduct() There are two inputs (A,B)
Please design a function to calculate the matrix multiplication PYTHON CODE:
you need to design a matrix multiplication function "MaxProduct()"
There are two inputs (A,B) and one ouput (the production of the two input A*B).
Assume all the inputs and test cases are orgnized in the format of 2-D array, i.e., row vector is a matrix with only 1 row and colomn vector is a matrix with only 1 column.
Assume the inputs are both matrix, you need to first check if the demension of the two matrix meets the requirment or not. If so, you will calculation the multiplication of the two. Otherwise please display the error info.
Assume one of the input could be a vector, you need to make sure your code could also work.
Assume both of the inputs could be vector, you need to make sure your code could also work
---------------------------------------------------------
def MaxProduct(A,B):
# Please add your code below
return C
# do not change the following code. Please use the following code to test your code.
a=[[1,2],[3,4],[5,6],[7,8]]
b=[[1,2,3],[1,2,3]]
c=[[1,2,3]]
d=[[1],[2]]
e=[[2,3,4,5,6]]
print(MaxProduct(a,b))
print(MaxProduct(b,a))
print(MaxProduct(a,c))
print(MaxProduct(a,d))
print(MaxProduct(c,a))
print(MaxProduct(d,c))
print(MaxProduct(b,e))
print(MaxProduct(e,d))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
