フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Modify an algorithm to perform vector operations by eliminating the inner most for loop

1 回表示 (過去 30 日間)
Pascale Bou Chahine
Pascale Bou Chahine 2020 年 9 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Let A and B be square matrices (both stored column-wise) in R^{nxn} with B an Upper Triangular matrix. Write the MATLAB algorithm that gives C = A x B.
Here's my algorithm
function C = scalarMultRegUpper(A,B)
[n,n] = size(A);
[n,n]=size(B);
C=zeros(n,n);
for j=1:n
for k=1:n
for i=1:n
C(i,j)=C(i,j) + B(k,j)*A(i,k);
end
end
end
Now, I'm asked to modify my algorithm to perform vector operations by eliminating the inner most for loop. How to do that? How will the algorithm change?
  11 件のコメント
Pascale Bou Chahine
Pascale Bou Chahine 2020 年 9 月 19 日
Oh okay, thank you. And what would the algorithm be if both matrices were upper triangular (in my understanding)?
Vladimir Sovkov
Vladimir Sovkov 2020 年 9 月 20 日
Analogously. Analyze which elements of A are zero with every fixed k and exlude them from the loop over i. The product of upper triangular matrices is the upper triangular matrix.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by