% multiply a tensor t by a matrix m from the left along the slices % orthogonal to dimension d function tnew = tleftmult(a,t,d) olddim = tdimensions(t); newdim = olddim; if d == 1, cdim = 2; else cdim = 1; end newdim(cdim) = size(a,1); tnew = tzeros(newdim); for s=1:olddim(d), tnew = tputmatrix(tnew,s,d,a*tgetmatrix(t,s,d)); end