Starting from:

$30

Math 1080 Homework #4

Math 1080
Homework #4

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

More products