Computers and Technology

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)?

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 04:00, china236
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
image
Computers and Technology, 23.06.2019 06:30, arguellesjavier15
Who can provide you with a new password when you have forgotten your old one? your provide you with a new password in case you forget your old one.
Answers: 3
image
Computers and Technology, 23.06.2019 09:00, Riddledjam44623
Before you record your own voice, you should a. record other people's voices b. warm up and practice difficult names c. listen to your favorite songs d. read a transcript of a good radio news segment
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, sophx
Apunishment or the threat of punishment used to enforce conformity. select the best answer from the choices provided t f
Answers: 1
Do you know the correct 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
Physics, 21.09.2021 08:50
Konu
Mathematics, 21.09.2021 08:50
Konu
Mathematics, 21.09.2021 08:50