Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago