% Creation of a translation matrix
% transmatxxl.M,   29.06.2004 XXL
% 
% function   P  =  transmatxxl(n,k); 
% Description : transmat(n,k) creates the translation matrix, that
%               shifts the columns of a MATRIX by k
%               P f (l ) = (f (l+k) mod n))
% 
% Input     :   n     = size of matrix 
%               k     = shift
%
% Output    :   T = the n x n permutation matrix 
% Comments  :   using P' shifts by -k.
%               multiplication to the right shifts columns by -k.
%               using right multiplikation and P' shifts by k.
%
% Copyright :  (c) Acoustics Research Institute, Austrian Academy of
%              Science
%              http://www.kfs.oeaw.ac.at
function   P=transmatxxl(n,k);

if nargin < 1
    disp('No input -> no output');
    return;
elseif nargin < 2
   k = 1;
end

P = rot(eye(n),k);

% direct:
% slower
% P1=eye(n);
% k = mod(k,n);
% P(1:(n-k),:) = P1((k+1):n,:);
% if k ~= 0
%    P((n-k+1):n,:) = P1(1:k,:);
% end

% Using the rot module
% this is about 4 times faster
% than the direct method

% for time evaluation:
% t1 = cputime;
% t2 = cputime;
% disp(t1-t);
% disp(t2-t1);
