Description
In all problems below let A be đť‘š Ă— đť‘› matrix, B be đť‘› Ă— đť‘› matrix, and v be a vector in â„ťđť‘›
.
Problem 1:
Exactly how many flops are needed to perform the following lines of code?
a) d = A*v;
b) C = A*B;
c) x = v’*B*v; (in Matlab syntax v’ represents the transpose of v.)
d) x = A(1:n,:)*(B*v);
e) x = (A(1:n,:)*B)*v; (this case differs from d) in the order of products)
Problem 2:
Exactly how many flops are needed to execute the following code segments?
a) for k = 1:n
a(k) = B(k,k)*v(n-k);
end
b) for k = 1:n
x = B(k,n-k+1:n)*v(n-k+1:n);
end
c) for k = 1:n-1
for j = n-k:n
c = c + B(:,1:j)*A(n-j+1:n,k);
end
end