-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
85 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function [] = flt(n) | ||
% Fast Legendre Transform, based on Alpert-Rokhlin | ||
|
||
% Initialization | ||
k=32; | ||
s=4*k; | ||
|
||
% Step 1 | ||
r=0:k-1; | ||
t=(1-cos((r+0.5)*pi/k))/2; | ||
tt=[t/2, (1+t)/2]; | ||
|
||
% Step 2 | ||
T=repmat(t,[k,1]); | ||
den=prod(T-T'+eye(k)); | ||
l=0:s-1; | ||
U=repmat(l/s,[k,1])-repmat(t(:),[1,s]); | ||
U=bsxfun(@rdivide, bsxfun(@rdivide, prod(U), U), den(:)); | ||
|
||
%Step 3 | ||
h=log2(n/s)-1; | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function [z] = idht(f, N) | ||
% Inverse Discrete Hermite Transform | ||
x=sqrt(pi/(2*N))*(-N:2:N-2); | ||
H=zeros(N,N); | ||
H(1,:)=pi^-(1/4)*exp(-x.^2/2); | ||
H(2,:)=sqrt(2)*x.*H(1,:); | ||
for i=1:N-2 | ||
H(i+2,:)=sqrt(2/(i+1))*x.*H(i+1,:)-sqrt(i/(i+1))*H(i,:); | ||
end | ||
z=sqrt(2*pi/N)*H*f(x'); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
function [x, w] = GaussChebyshev(a, b, n) | ||
% Returns abscissas and weights for the Gauss-Chebyshev n-point quadrature | ||
% over the interval [a, b]. Weigths include reciprocal weight function. | ||
th=((1:n)-1/2)*pi/n; | ||
% over the interval [a, b]. | ||
th=pi*(1:2:2*n-1)/(2*n); | ||
x=(b-a)/2*cos(th)+(a+b)/2; | ||
w=(b-a)*pi/(2*n)*sin(th); | ||
w(1:n)=(b-a)*pi/(2*n); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
function [x, w] = GaussHermite(n) | ||
function [x, w] = GaussHermite(n, mu, sigma) | ||
% Returns abscissas and weights for the Gauss-Hermite n-point quadrature | ||
% over the interval [-inf, inf] using the Golub-Welsch Algorithm. | ||
beta=sqrt((1:n-1)/2); | ||
[x,V]=trideigs(zeros(1,n), beta); | ||
x=x'; w=sqrt(pi)*V(1,:).^2; | ||
x=(sqrt(2)*sigma)*x'+mu; | ||
w=sqrt(2*pi)*sigma*V(1,:).^2; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,10 @@ | ||
function [p] = Lagrange(x, y, t) | ||
% Evaluates the Lagrange interpolation polynomial. | ||
n=length(x); | ||
w=ones(size(x)); | ||
for i=1:n | ||
for j=1:n | ||
if j~=i | ||
w(i)=w(i)*(x(i)-x(j)); | ||
end | ||
end | ||
end | ||
g=1; | ||
p=0; | ||
for k=1:n | ||
d=t-x(k); | ||
p=p+y(k)./(w(k)*d); | ||
g=g.*d; | ||
end | ||
p=g.*p; | ||
n=length(x); | ||
m=length(t); | ||
X=repmat(x(:).',[n,1]); | ||
w=prod(X-X.'+eye(n)); | ||
r=y./w; | ||
D=repmat(t(:).',[n,1])-repmat(x(:),[1,m]); | ||
p=prod(D).*(r*(1./D)); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function [y]=HermitePsi(a, x) | ||
% Evaluates the Hermite function series given by the coefficients a(n) | ||
n=length(a); | ||
y=(n>1)*a(n); yy=zeros(size(x)); | ||
for k=n-2:-1:1 | ||
temp=y; | ||
y=a(k+1)+sqrt(2/(k+1))*x.*y-sqrt((k+1)/(k+2))*yy; | ||
yy=temp; | ||
end | ||
h0=pi^(-1/4)*exp(-x.^2/2); | ||
y=h0.*(a(1)+sqrt(2)*x.*y-sqrt(1/2)*yy); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function [j] = jinc(a,x) | ||
t=(x==0); | ||
j=(besselj(a,x)+t)./(x+t); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function [y] = sinc(x) | ||
t=(x==0); | ||
y=(sin(x)+t)./(x+t); | ||
end | ||
|
Binary file not shown.