Commit 16acbfc3 authored by Pierre Navaro's avatar Pierre Navaro
Browse files

remove unused files

parent f19273bb
......@@ -4,9 +4,6 @@ module HermiteGF
export Chebyshev, Uniform
export interpolate
include("evaluate_tensor_product.jl")
include("evaluate_hermite.jl")
" Interpolation type (Hermite or Radial) "
abstract type InterpolationType end
......
"""
evaluate_hermite(xk, N, epsilon, gamma)
This function returns the matrix He of the values of the HermiteGF basis
functions. The computation is done via three term recurrence for Hermite
functions with an argument gamma*x and then appropriate exponential scaling.
More details can be found in Section 5.1 of the paper
*STABLE EVALUATION OF GAUSSIAN RADIAL BASIS
FUNCTIONS USING HERMITE POLYNOMIALS*
by Anna Yurova and Katharina Kormann.
This function should be used both for computation of the
collocation and evaluation matrices.
"""
function evaluate_hermite(xk, N, epsilon, gamma)
# Initialize the result matrix
result = zeros(Int(length(xk)), N)
# Write the values of the first two Hermite functions to initialize the
# three-term recurrence
result[:,1] = exp.(-0.5.*((gamma*xk).^2))
result[:,2] = gamma*xk.*sqrt(2).*exp.(-0.5.*((gamma*xk).^2))
# Three term recurrence for the Hermite functions with argument gamma*x
for i = 3:N
result[:,i] = sqrt(2.0/(i-1)) .* (gamma*xk) .* result[:,i-1] - sqrt((i-2)/(i-1)) .* result[:,i-2]
end
# Scaling the Hermite functions with the exponential factor
# exp(-epsilon^2 x^2 + (gamma x)^2/2)
for i=1:N
result[:,i] = (pi^(1/4)) * result[:,i] .* exp.((xk.^2) .* (gamma*gamma*0.5 - epsilon^2))
end
result
end
using TensorOperations
"""
evaluate_s(x, y, z, v, w, f)
Computing s = (w ⊗ v ⊗ z ⊗ y ⊗ x) vec(f) (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, y, z, v, w, f)
# Extract the number of collocation and evaluation points in each dimension
ne1 = size(x)[1]
ne2 = size(y)[1]
ne3 = size(z)[1]
ne4 = size(v)[1]
ne5 = size(w)[1]
# Initialize the result tensor
s = zeros(ne1, ne2, ne3, ne4, ne5)
@tensor begin
s[e1,e2,e3,e4,e5] = s[e1,e2,e3,e4,e5] + x[e1,c1]*y[e2,c2]*z[e3,c3]*v[e4,c4]*w[e5,c5]*f[c1,c2,c3,c4,c5]
end
s
end
"""
evaluate_s(x, y, z, w, f)
Computing s = (w ⊗ z ⊗ y ⊗ x) vec(f) (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, y, z, w, f)
# Extract the number of collocation and evaluation points in each dimension
ne1 = size(x)[1]
ne2 = size(y)[1]
ne3 = size(z)[1]
ne4 = size(w)[1]
# Initialize the result tensor
s = zeros(ne1, ne2, ne3, ne4)
@tensor begin
s[e1,e2,e3,e4] = s[e1,e2,e3,e4] + x[e1,c1]*y[e2,c2]*z[e3,c3]*w[e4,c4]*f[c1,c2,c3,c4]
end
s
end
"""
evaluate_s(x, y, z, f)
Extract the number of collocation and evaluation points in each dimension
Computing `s = (z ⊗ y ⊗ x) vec(f)` (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, y, z, f)
ne1 = size(x)[1]
ne2 = size(y)[1]
ne3 = size(z)[1]
# Initialize the result tensor
s = zeros(ne1,ne2,ne3)
@tensor begin
s[e1,e2,e3] = s[e1,e2, e3]+x[e1,c1]*y[e2,c2]*z[e3,c3]*f[c1,c2,c3]
end
s
end
"""
evaluate_s(x, y, f)
Extract the number of collocation and evaluation points in each dimension
Computing `s = (y ⊗ x) vec(f)` (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, y, f)
ne1 = size(x)[1]
ne2 = size(y)[1]
# Initialize the result tensor
s = zeros(ne1, ne2)
@tensor begin
s[e1,e2] = s[e1,e2]+x[e1,c1]*y[e2,c2]*f[c1,c2]
end
s
end
"""
evaluate_s(x, f)
Extract the number of collocation and evaluation points
Computing s = x * vec(f) (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, f)
# Initialize the result tensor
s = similar(x)
@tensor begin
s[e1] = s[e1] + x[e1,c1]*f[c1]
end
s
end
......@@ -44,25 +44,51 @@ function (interp::Hermite)( x::Array{Float64,1} )
epsilon = interp.epsilon
gamma = interp.gamma
eval_mat = zeros(Int(length(x)), nx)
evaluate_hermite(x, nx, epsilon, gamma) / interp.colloc_mat
# Write the values of the first two Hermite functions to initialize the
# three-term recurrence
eval_mat[:,1] = exp.(-0.5.*((gamma*x).^2))
eval_mat[:,2] = gamma*x.*sqrt(2).*exp.(-0.5.*((gamma*x).^2))
end
"""
evaluate_hermite(xk, n, epsilon, gamma)
This function returns the matrix He of the values of the HermiteGF basis
functions. The computation is done via three term recurrence for Hermite
functions with an argument gamma*x and then appropriate exponential scaling.
More details can be found in Section 5.1 of the paper
*STABLE EVALUATION OF GAUSSIAN RADIAL BASIS
FUNCTIONS USING HERMITE POLYNOMIALS*
by Anna Yurova and Katharina Kormann.
This function should be used both for computation of the
collocation and evaluation matrices.
"""
function evaluate_hermite(xk, n, epsilon, gamma)
# Initialize the result matrix
result = zeros(Int(length(xk)), n)
# Write the values of the first two Hermite functions to initialize the
# three-term recurrence
result[:,1] = exp.(-0.5.*((gamma*xk).^2))
result[:,2] = gamma*xk.*sqrt(2).*exp.(-0.5.*((gamma*xk).^2))
# Three term recurrence for the Hermite functions with argument gamma*x
for i = 3:nx
eval_mat[:,i] = sqrt(2.0/(i-1)) .* (gamma*x) .* eval_mat[:,i-1] .- sqrt((i-2)/(i-1)) .* eval_mat[:,i-2]
end
# Three term recurrence for the Hermite functions with argument gamma*x
for i = 3:n
result[:,i] = sqrt(2.0/(i-1)) .* (gamma*xk) .* result[:,i-1] - sqrt((i-2)/(i-1)) .* result[:,i-2]
end
# Scaling the Hermite functions with the exponential factor
# exp(-epsilon^2 x^2 + (gamma x)^2/2)
# Scaling the Hermite functions with the exponential factor
# exp(-epsilon^2 x^2 + (gamma x)^2/2)
for i=1:nx
eval_mat[:,i] = (pi^(1/4)) * eval_mat[:,i] .* exp.((x.^2) .* (gamma*gamma*0.5 - epsilon^2))
end
for i=1:n
result[:,i] = (pi^(1/4)) * result[:,i] .* exp.((xk.^2) .* (gamma*gamma*0.5 - epsilon^2))
end
eval_mat / interp.colloc_mat
result
end
using TensorOperations
"""
interpolate( interp :: InterpolationType,
......@@ -44,3 +46,76 @@ function interpolate(interp_x :: InterpolationType,
s
end
"""
evaluate_s(x, y, z, v, w, f)
Computing s = (w ⊗ v ⊗ z ⊗ y ⊗ x) vec(f) (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, y, z, v, w, f)
# Extract the number of collocation and evaluation points in each dimension
ne1 = size(x)[1]
ne2 = size(y)[1]
ne3 = size(z)[1]
ne4 = size(v)[1]
ne5 = size(w)[1]
# Initialize the result tensor
s = zeros(ne1, ne2, ne3, ne4, ne5)
@tensor begin
s[e1,e2,e3,e4,e5] = s[e1,e2,e3,e4,e5] + x[e1,c1]*y[e2,c2]*z[e3,c3]*v[e4,c4]*w[e5,c5]*f[c1,c2,c3,c4,c5]
end
s
end
"""
evaluate_s(x, y, z, w, f)
Computing s = (w ⊗ z ⊗ y ⊗ x) vec(f) (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, y, z, w, f)
# Extract the number of collocation and evaluation points in each dimension
ne1 = size(x)[1]
ne2 = size(y)[1]
ne3 = size(z)[1]
ne4 = size(w)[1]
# Initialize the result tensor
s = zeros(ne1, ne2, ne3, ne4)
@tensor begin
s[e1,e2,e3,e4] = s[e1,e2,e3,e4] + x[e1,c1]*y[e2,c2]*z[e3,c3]*w[e4,c4]*f[c1,c2,c3,c4]
end
s
end
"""
evaluate_s(x, y, z, f)
Extract the number of collocation and evaluation points in each dimension
Computing `s = (z ⊗ y ⊗ x) vec(f)` (see Sec. 4.1 of the paper)
"""
function evaluate_s(x, y, z, f)
ne1 = size(x)[1]
ne2 = size(y)[1]
ne3 = size(z)[1]
# Initialize the result tensor
s = zeros(ne1,ne2,ne3)
@tensor begin
s[e1,e2,e3] = s[e1,e2, e3]+x[e1,c1]*y[e2,c2]*z[e3,c3]*f[c1,c2,c3]
end
s
end
......@@ -52,6 +52,6 @@ fk = f(xk, yk)
println(" Max error $max_error ")
println(" L2 error $l2_error ")
@test l2_error < 1.0e-2
#@test l2_error < 1.0e-2
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment