Dot product of tensor
Show older comments
Hi, I have two tensors A and B, of sizes (ma, na, 3), and (mb, nb, 3).
I would like to create C of size(ma, na, mb, nb) with C(i,j,k,h) = dot(A(i,j,:),B(k,h,:));
What is the fastest and most memory efficient way of achieving this? Many thanks!
Accepted Answer
More Answers (1)
Ar=reshape(A,[],3);
Br=reshape(B,[],3);
C=reshape( Ar*Br.' ,ma,na,mb,nb);
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!