Question: Write a function called operations that takes three inputs: a real number c (a float) and two matrices A and B (numpy arrays). It
Write a function called operations that takes three inputs: a real number c (a float) and two matrices A and B (numpy arrays). It should return a dictionary that has seven key-value pairs: shape: the shape of A (as a tuple) scale: A scaled by c (as a numpy array) sum: A plus B (as a numpy array) difference: A minus B (as a numpy array) elementwise_multiplication: elementwise multiplication between A and B (as a numpy array) matrix_multiplication: matrix multiplication between A and B (as a numpy array) transpose: A transposed (as a numpy array) If the shapes of A and B are such that a certain key's value is not mathematically possible, then make its value the string "not possible". def operations (c,A,B): # YOUR CODE HERE raise Not ImplementedError() #hidden tests for problem 1.1 are within this cell Write a function called det_and_inv that takes as an input a square matrix (a numpy array) and returns a tuple with two elements (a) the determinant, and (b) the inverse if it mathematically exists and the string "does not exist* otherwise. def det_and_inv(square_matrix): # YOUR CODE HERE raise Not ImplementedError()
Step by Step Solution
There are 3 Steps involved in it
Solution Here are the implementations of the operations and detandinv functions import numpy as np d... View full answer
Get step-by-step solutions from verified subject matter experts
