Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 2 0 : Complexity calculation The command flops used to be available in early versions of Matlab. Currently, cputime, etime, tic / toc are

Q20: Complexity calculation
The command flops used to be available in early versions of Matlab. Currently, cputime, etime, tic/toc are the only available commands if you want to indirectly evaluate complexity.
Let AinRmn,nRn. Consider the matrix vector product y=Ax. By definition,
yi=j=1naijxj,i=1,dots,m.
Modify this expression for the case where A is a dense lower-triangular matrix, so that operations with the zero entries in A are excluded.
Implement your modified expression using the nested loop below so that it computes the matrix-vector product, while at the same time it updates a variable flops that counts the number of operations to termination.
rng(20); m=randi([1120]); n= randi(10);%---> SETUP: do not edit
A=tril(randn(m,n));x=randn(n,1);%-cdots SETUP: do not edit
y=zeros(m,1);
flops =0;
for i=1:1
for j=1:1
y=y;
flops=flops;
end
image text in transcribed

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

Introduction to Chemical Engineering Thermodynamics

Authors: J. M. Smith, H. C. Van Ness, M. M. Abbott

7th edition

71247084, 978-0071247085

More Books

Students also viewed these Chemical Engineering questions