Question: 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
 Q20: Complexity calculation The command flops used to be available in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Chemical Engineering Questions!