An algorithm I\'m working on requires computing, in a couple places, a type of matrix triple product.
The operation takes three square matrices with identical dimens
I know this is a bit old now but this topic comes up a lot. In Matlab it is hard to beat tprod, a MEX file written by Jason Farquhar available here
https://www.mathworks.com/matlabcentral/fileexchange/16275-tprod-arbitary-tensor-products-between-n-d-arrays
tprod works a lot like einsum though it is limited to a binary operation (2 tensors). This is probably not really a limitation because I suspect that einsum simply performs a series of binary operations. The order of these operations makes a big difference and my understanding is that einsum simply performs them in the order the arrays are passed and does not allow multiple intermediate products.
tprod also is limited to dense (full) arrays. Kolda's Tensor Toolbox (mentioned in an earlier post) does support sparse tensors but is more limited in its functionality than tprod (it does not allow repeated indices in the output). I am working on filling these gaps but wouldn't it be nice if Mathworks did it?