Question
Write a function my_function(mat 1, mat 2) that replicates the numpy method dot using loops. Your function should take in two numpy arrays and output
Write a function my_function(mat 1, mat 2) that replicates the numpy method dot using loops.
Your function should take in two numpy arrays and output a numpy array with the same number of rows as mat 1 and the same number of columns as mat 2.
It should use three nested loops, one for the row of the output, one for the column of the output, and one for the sum taken on the multiplication along the elements the corresponding row of mat 1 and column of mat 2.
The element in row i and column j of your output array should equal Pn k=1 mat 1i,k mat 2k,j , where the number As,t is the element in row s and column t of the array A.
You can use the command mat 1.dot(mat 2) to produce the output for a test case.
Your function should return None and print a warning message if the matrices are not conformable; that is, if the number of rows of mat 2 is not equal to number of columns of mat 1.
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