function [DT,ind_diag]=diagT(ddT)

% this function obtains pages of diagonals matrices 
%using as diagonals the columns of ddt matrix 
%ddt  is nxT
% Copyright (c) 2013-2018, Francesco Corsello, All Rights Reserved.

[n,T]=size(ddT);

%ind_diag=(n^2)*vec(repmat(0:(T-1),[n,1]))+repmat([1:n+1:(n^2)]',[T,1]);
ind_diag=logical(repmat(eye(n),[1,1,T]));

DT=zeros([n,n,T]);
DT(ind_diag)=ddT(:);