% dimensions of a tensor (returns either a row vector or three scalars)

function [d,m,n] = tdimensions(t)

if size(t) == [0 0],
  d = [0 0 0];
else
  d = zeros(1,3);
  d(1) = size(t,1);
  cols = size(t,2);
  d(2) = t(1,cols);
  d(3) = (cols-1)/d(2);
end

if nargout == 3,
  m = d(2);
  n = d(3);
  d = d(1);
elseif nargout ~= 0 & nargout ~= 1,
  error('either zero, one or three output variables are required')
end
