Matlab is great for working with vectors and matrices, but higher-order tensors are poorly supported. Even something as simple as multiplying a 3d matrix with a vector — in Einstein notation, — is a pain. I’ve tried different toolboxes before, as well as my own workarounds based on reshape and permute, but I was never really satistified with the syntax.
TPROD looks like an interesting toolbox. Basically it allows one to use Einstein tensor notation to specify a product. So for example, the above would translate into:
C = etprod('ij',M,'ijk',v,'k');
In addition to such reductions, it can perform outer products, traces and assorted exotic tensor-tensor products. AFAIK, the core operations are implemented in C. Check it out here.