% return the submatrix indices corresponding to the subtensor of t % specified by the index range arguments; a range argument can be ':' % (alas, with the quotes) to specify the whole range; also returns % the dimensions d of the subtensor function [rows,cols,d] = tstorage(t,ir,jr,kr) tcols = size(t,2)-1; tdim = tdimensions(t); l = tdim(1); m = tdim(2); n = tdim(3); if ir == ':', ir = 1:l; end if jr == ':', jr = 1:m; end if kr == ':', kr = 1:n; end if any(ir < 1) | any(ir > l) | ... any(jr < 1) | any(jr > m) | ... any(kr < 1) | any(kr > n), error('subscript out of range') end rows = ir; kcols = m*(kr-1); cols = (jr(:)*ones(1,length(kcols))) + (ones(length(jr),1)*kcols(:)'); cols = cols(:); d = [length(ir) length(jr) length(kr)];