Question: We saw that the complexity of matrix-vector multiplication is O(n2). Use your mat_vec_gen(n) function and record the time needed to multiply an nn matrix by

We saw that the complexity of matrix-vector multiplication is O(n2). Use your mat_vec_gen(n) function and record the time needed to multiply an nn 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.

mat_vec_gen(n) is:We saw that the complexity of matrix-vector multiplication is O(n2). Use your

from random import randint def mat_vec_gen(n): [[randint (1,100) for ii in range(n)] [randint (1,100) for 11 in range (n)] -A for JJ in range(n)] -"x = result- for i in range(n) total = 0 for j in range(n): -, total +=A[i][j] *x[j] result.append (total) return A, x

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!