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

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:30
You picked the corridor which led you here. if the guards find you, they're going to be really angry! what is the synonym of angry
Answers: 1
question
Computers and Technology, 22.06.2019 00:30
To insert a column without using commands in any tabs, a user can -click and then click insert column.
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
For her science class, elaine is creating a presentation on weather in the united states. she wants to make the presentation beautiful and interesting by drawing simple cloud or wave shapes. which is the best way for elaine to draw these shapes?
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
What is the most important for you to choose before you build a network?
Answers: 1
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
question
History, 23.05.2021 05:20
question
History, 23.05.2021 05:20
question
English, 23.05.2021 05:20
question
Mathematics, 23.05.2021 05:20
question
Mathematics, 23.05.2021 05:20
Questions on the website: 13722361