sweep of tensor products
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have two matrces A of dimension c x n and B of dimension c x l with c >> n and c >> l
I would like to calculate the tensor C of dimesion c x (n x l) wht C_i,j,k = A_i_j * B_i_k
Is there a way to imrpove the following code ?
Thank you in advance,
c = 100;
n = 5;
l = 10;
A = rand(c, n);
B = rand(c, l);
C = nan([ c n l] );
for ii = 1:c
C(ii,:,:) = tensorprod(A(ii,:),B(ii,:));
end
0 件のコメント
採用された回答
Bruno Luong
2024 年 11 月 5 日
編集済み: Bruno Luong
2024 年 11 月 5 日
Strictly speaking you do not compute a tensor product.
c = 100;
n = 5;
l = 10;
A = rand(c, n);
B = rand(c, l);
C = A .* reshape(B, c, 1, l);
size(C)
3 件のコメント
Matt J
2024 年 11 月 6 日
Strictly speaking you do not compute a tensor product.
It is essentially, a Khatri-Rao product.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Genomics and Next Generation Sequencing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!