% returns the subtensor of t specified by the given index ranges;
% a range argument can be ':' (alas, with quotes) to denote the whole
% range; warning: matrix outputs are still represented as tensors;
% use tgetmatrix to get a regular matrix

function ts = tgetsubtensor(t,ir,jr,kr)

[r,c,dim] = tstorage(t,ir,jr,kr);
ts = tzeros(dim);
ts(:,1:(size(ts,2)-1)) = t(r,c);
