Question: (a) Write a function called mat vec) that takes as input a square matrix and a vector of compatible dimensions, and returns the resulting product

 (a) Write a function called mat vec) that takes as input

(a) Write a function called mat vec) that takes as input a square matrix and a vector of compatible dimensions, and returns the resulting product vector. That is. if the input are an n n matrix A and an n 1 vector x. then mat-vec (A,x)= Ax. Test your function on small matrices and vectors that you can check by hand. When you are satisfied, move on to parts (b) and (c). Additionally, print out your code for this function and include it with your assignment. (b) We saw that the complexity of matrix-vector multiplication is 0(n2). Use your mat.vec) function and record the time needed to multiply an n n matrix by a vector of length n, for n sizes 10,20, 40, 80, 160, 320,640, 1280, 2560,5120, 10240]. Store these timing estimates in a list (say, timing). Create a plot of the matrix sizes (sizes) on the horizontal axis versus the run-times to perform the multiplications (timing) on the vertical axis. Be sure to label your axes! Include a print-out of this plot with your assignment. Write a sentence or two about whether or not the shape of this plot matches your expectations based on the complexity of matrix-vector multiplication (c) Compute the ratios of timings for consecutive matrix/vector sizes and store them in the list ratios. Specifically, ratios [1] timings [i+1] /timings [1]. Print out the list and include it with your assignment. Write a sentence or two about whether or not the values of these ratios match your expectations based on the complexity of matrix-vector multiplication. You may find it helpful to make a plot of ratios as a function of sizes, but this is not required

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!