フィルターのクリア

Matrix Multiplication for each row

2 ビュー (過去 30 日間)
Ankush Kumar Mishra
Ankush Kumar Mishra 2021 年 10 月 21 日
コメント済み: Ankush Kumar Mishra 2021 年 10 月 21 日
I have a matrix A = 100000*2 and matrix B which is a symmetric square matrix with number of row and columns equal to the number of columns of A.
I want to compute diag (A*B*A') but since A*B*A' is 100000*100000, matlab cannot compute it and then give diagonal of it. Any workaround?
What i am actually looking for is The first row of A multiplied by B and then multiplied by first column of A'. Now, I can perform this 100000 times to get 100000*1 matrix but that is time consuming. Any workaround will be appreciated?

採用された回答

Chunru
Chunru 2021 年 10 月 21 日
n = 5; %100000
A = randn(n, 2);
B = [4 2; 2 3];
if n<100
d1 = diag(A*B*A')
end
d1 = 5×1
4.3969 45.0577 9.4548 6.3347 1.4279
d2 = sum(A.*(A*B'), 2)
d2 = 5×1
4.3969 45.0577 9.4548 6.3347 1.4279
  1 件のコメント
Ankush Kumar Mishra
Ankush Kumar Mishra 2021 年 10 月 21 日
Thanks, that worked!!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by