How to operate with multidimensional arrays (Einstein summation)?
Show older comments
Let's imagine that I have an array of dimension 4 (A_ijkl) that I want to multiply with an array of dimension 2 (B_kl) to obtain an array of dimension 2 (C_ij; i.e., summing over indices k and l). What could be the most efficient (and clean) manner of doing so in Matlab?
And let's go one step further, what if we want to do C_ijxy=A_ijklxy * B_klxy ?
Thank you
Accepted Answer
More Answers (1)
Chern Hui Lee
on 4 Apr 2025
0 votes
For future reference, there is a function tensorprod available since R2022a that does exactly this.
https://www.mathworks.com/help/matlab/ref/tensorprod.html
Categories
Find more on Fractals 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!