Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Follow the function design recipe to define functions for all of the following Exercises. For each function, create three examples to test your functions. Record
Follow the function design recipe to define functions for all of the following Exercises. For each function, create three examples to test your functions. Record the definitions in the sample script my A4 functions.py Example 1 Write a function matrix multiply(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 nat 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 EX_1 mat_1, x mat_2kg, where the number As,t is the clement in rows and columni 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