Home > tt2 > exp > fclencurt.m

fclencurt

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function [x,w]=fclencurt(N1,a,b)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 fclencurt.m - Fast Clenshaw Curtis Quadrature

 Compute the N nodes and weights for Clenshaw-Curtis
 Quadrature on the interval [a,b]. Unlike Gauss 
 quadratures, Clenshaw-Curtis is only exact for 
 polynomials up to order N, however, using the FFT
 algorithm, the weights and nodes are computed in linear
 time. This script will calculate for N=2^20+1 (1048577
 points) in about 5 seconds on a normal laptop computer.

 Written by: Greg von Winckel - 02/12/2005
 Contact: gregvw(at)chtm(dot)unm(dot)edu

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x,w]=fclencurt(N1,a,b)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % fclencurt.m - Fast Clenshaw Curtis Quadrature
0006 %
0007 % Compute the N nodes and weights for Clenshaw-Curtis
0008 % Quadrature on the interval [a,b]. Unlike Gauss
0009 % quadratures, Clenshaw-Curtis is only exact for
0010 % polynomials up to order N, however, using the FFT
0011 % algorithm, the weights and nodes are computed in linear
0012 % time. This script will calculate for N=2^20+1 (1048577
0013 % points) in about 5 seconds on a normal laptop computer.
0014 %
0015 % Written by: Greg von Winckel - 02/12/2005
0016 % Contact: gregvw(at)chtm(dot)unm(dot)edu
0017 %
0018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0019 
0020 N=N1-1; bma=b-a;
0021 c=zeros(N1,2);
0022 c(1:2:N1,1)=(2./[1 1-(2:2:N).^2 ])'; c(2,2)=1;
0023 f=real(ifft([c(1:N1,:);c(N:-1:2,:)]));
0024 w=bma*([f(1,1); 2*f(2:N,1); f(N1,1)])/2;
0025 x=0.5*((b+a)+N*bma*f(1:N1,2));

Generated on Wed 08-Feb-2012 18:20:24 by m2html © 2005