Code covered by the BSD License  

Highlights from
Chebpack

image thumbnail

Chebpack

by

 

15 Jul 2011 (Updated )

The MATLAB package Chebpack solves specific problems for differential or integral equations.

[J,J0]=prim(n,dom)
function [J,J0]=prim(n,dom)
% J: the matrix of the spectral primitive (sparse)
% J0: the matrix of the primitive vanishing at dom(1)
% n: dimension, dom: the domain [a,b]
% 
%    Written by Damian Trif, 2011
%
e1=1/2./(1:n);e2=[0 1/2 -1/2./(1:n-2)];
J=spdiags([e1' e2'],[-1 1],n,n);
alpha=(dom(2)-dom(1))/2;
J=J*alpha;
if nargout==2 %nargin==2
    T=cpv(n,dom(1),dom);
    M=speye(n);M(1,:)=-2*T;M(1,1)=0;
    J0=M*J;
end

Contact us