from
ChebyshevTools
by Michael Watson Tool box for solving ODE/PDEs using spectral Chebyshev differentiation matrices.
A=expD(M,ord,mod);
function A=expD(M,ord,mod);
if nargin==1
ord=1;
mod=0;
elseif nargin==2
mod=0;
end
% build the matrix operator A = Exp[D^ord]
D=deriv(M)^ord;
A=zeros(M);
for j=1:ceil(M/ord)
A=A+(D^(j-1))*(1/factorial(j-1));
end
%modify the first line
if (mod==1)
A(1,:)=A(1,:)*2;
end