from
ChebyshevTools
by Michael Watson Tool box for solving ODE/PDEs using spectral Chebyshev differentiation matrices.
B=inv_derivP(M,P)
function B=inv_derivP(M,P)
%this function returns the Pth quasi inverse for Chebycheb differentiation
%matrices st. iDP*DP=I_P
if P==1
B=inv_deriv1(M);
B(:,end)=0;
else
B=inv_deriv1(M+P);
B=B^P;
B(1:P,:)=0;
B=B(1:M,1:M);
B(:,end-P+1:end)=0;
end
B=sparse(B);