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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started