subject

P1. Write a MATLAB function with inputs • m and n, two positive integers, • a matrix A of size m × n, • a vector x of size n × 1, and which outputs the product vector A × x (note that the size of this vector should be m × 1). Your code should check that the sizes of the inputs are right and then do the multiplication using two nested "for" loops. a) How many floating point operations (additions and multiplications) does the code use? Find a formula in terms of m and n. b) Run the code with n = 100, m = 100, and inputs A =rand(m, n) and x =rand(n, 1). Modify the function by introducing a new output variable, op count, which initializes to 0 outside of the nested for loops (just like we did with product in class) and is incremented inside the innermost of the for loops by the number of operations done to update product. (We will do an example of this on Wednesday.) Output op count as well as product. Repeat the experiment for m = 200, n = 100; m = 100, n = 200; and m = n = 200. Do the ratios of the new op count outputs to the old one you got for m = n = 100 confirm the floating point operation formula you found in part a)?

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 00:30, haileesprague575
Quic which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
image
Computers and Technology, 23.06.2019 01:20, shiann2002
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
image
Computers and Technology, 23.06.2019 20:10, banna01man
Leo is a recruitment executive for a large company. he has identified new labor resource requirements in both the marketing and production departments. what should be his first step in recruiting candidates for the positions? a. conduct background checks of candidates b. make job offers c. arrange interviews d. conduct reference checks e. place job ads on job sites
Answers: 1
image
Computers and Technology, 24.06.2019 00:00, miguelturner
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
You know the right answer?
P1. Write a MATLAB function with inputs • m and n, two positive integers, • a matrix A of size m × n...

Questions in other subjects:

Konu
Social Studies, 14.11.2019 13:31