Commit 0c9dbd4c authored by Pierre Navaro's avatar Pierre Navaro
Browse files

Fix error in hermite

parent cc080df6
This diff is collapsed.
%% Cell type:code id: tags:
``` julia
using Plots
pyplot()
```
%% Output
Plots.PyPlotBackend()
%% Cell type:markdown id: tags:
HermiteGf is a julia package, install it with
```julia
using Pkg
Pkg.add("https://gitlab.mpcdf.mpg.de/clapp/HermiteGF.jl")
```
%% Cell type:code id: tags:
``` julia
using HermiteGF
```
%% Output
┌ Info: Recompiling stale cache file /Users/navaro/.julia/compiled/v1.0/HermiteGF/V9Jve.ji for HermiteGF [6d312152-d853-11e8-033d-978d5c49d094]
└ @ Base loading.jl:1187
%% Cell type:code id: tags:
``` julia
import HermiteGF:trapz
```
%% Cell type:code id: tags:
``` julia
xmin, xmax, nx = -1, 1, 32
ϵ, γ = 0.1, 3.0
interp = Hermite(Chebyshev(xmin, xmax, nx), 0.1, 3.0)
xk = interp.xk
f = cos.(xk.^2)
xe = collect(range(xmin, stop=xmax, length=nx))
dx = xe[2]-xe[1]
fe = cos.(xe.^2)
s = interpolate( interp, f, xe )
sqrt(trapz((s - fe).^2, dx)), maximum(abs.(s .- fe))
```
%% Output
MethodError: no method matching Hermite(::Chebyshev, ::Float64, ::Int64)
Stacktrace:
[1] top-level scope at In[4]:2
%% Cell type:code id: tags:
``` julia
xmin, xmax, nx = -1, 1, 8
xe = collect(range(xmin, stop=xmax, length=nx))
fe = cos.(xe.^2)
```
%% Output
8-element Array{Float64,1}:
0.5403023058681398
0.8726448614622705
0.9831793964382022
0.9997917606637399
0.9997917606637399
0.9831793964382022
0.8726448614622705
0.5403023058681398
%% Cell type:code id: tags:
``` julia
hermite_chebyshev = Hermite(Chebyshev(xmin, xmax, nx), 0.1, 3)
xk = hermite_chebyshev.xk
f = cos.(xk.^2)
scatter(xe, interpolate( hermite_chebyshev, f, xe );
label = "chebyshev")
plot!(xe, fe; label="f", title="Hermite-Chebyshev")
```
%% Output
MethodError: no method matching Hermite(::Chebyshev, ::Float64, ::Int64)
Stacktrace:
[1] top-level scope at In[6]:1
%% Cell type:code id: tags:
``` julia
hermite_uniform = Hermite(Uniform( xmin, xmax, nx), 0.1, 3)
xk = hermite_uniform.xk
f = cos.(xk.^2)
scatter!(xe, interpolate( hermite_uniform, f, xe );
label="uniform")
plot!(xe, fe; label="f", title="Hermite-Uniform")
```
%% Output
MethodError: no method matching Hermite(::Uniform, ::Float64, ::Int64)
Stacktrace:
[1] top-level scope at In[7]:1
%% Cell type:code id: tags:
``` julia
```
"""
Hermite( nodes::NodesType, epsilon, gamma )
Hermite( nodes::NodesType, epsilon:Real, gamma:Real )
Hermite inteprolation
"""
mutable struct Hermite <: InterpolationType
nx :: Vector{Int64}
epsilon :: Vector{Float64}
gamma :: Vector{Float64}
nx :: Int64
epsilon :: Float64
gamma :: Float64
xk :: Vector{Array{Float64,1}}
colloc_mat :: AbstractVecOrMat{Float64}
function Hermite( nodes::Vector{NodesType},
epsilon::Vector{Float64},
gamma::Vector{Float64} )
function Hermite( nodes::Vector{NodesType}, epsilon::Real, gamma::Real )
xk = nodes.xk
nx = nodes.nx
......
......@@ -11,7 +11,7 @@ mutable struct Radial <: InterpolationType
xk :: Array{Float64,1}
colloc_mat :: Array{Float64,2}
function Radial( nodes::NodesType, epsilon )
function Radial( nodes::NodesType, epsilon::Real )
xk = nodes.xk
nx = nodes.nx
......
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