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.

A=fact(a,m)
function A=fact(a,m)
% A: the "multiplication by a(x)" matrix A (sparse)
% a: the n coefficients of the function a(x)
% m: truncation order of a(x), m<=n
%
%    Written by Damian Trif, 2011
%
n=length(a);if nargin<2, m=n;end
a(1)=a(1)/2;b=ones(n,1);b(1)=1/2;
N=m+n-1;c=zeros(N,n);
for i=0:m-1
    for j=0:n-1
        c(i+j+1,j+1)=c(i+j+1,j+1)+a(i+1)*b(j+1)/2;
        c(abs(i-j)+1,j+1)=c(abs(i-j)+1,j+1)+a(i+1)*b(j+1)/2;
    end;
end;
c(1,:)=c(1,:)*2;A=sparse(c(1:n,:));

Contact us