% computeTdk(d,k,M) computes the matrix T_d^k(M). See the
% text of the paper for the definition of T_d^k(M).

function Tdk = computeTdk(d,k,M)

if (k < d) error('must have k >= d'); end

[rowsizeM,colsizeM] = size(M);
if (rem(rowsizeM,d+1) ~= 0)
  error('rowsize of M must be divisible by d+1');
end
n = rowsizeM/(d+1);
r = colsizeM;
Tdk = zeros((k+1)*n,(k-d+1)*r);

for j=1:k-d+1
  Tdk((j-1)*n+1:(j-1)*n+rowsizeM,(j-1)*r+1:j*r) = M;
end
