Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/basis/basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,3 @@ unicode_order(::Val{6}) = "⁶"
unicode_order(::Val{7}) = "⁷"
unicode_order(::Val{8}) = "⁸"
unicode_order(::Val{9}) = "⁹"

function Base.show(io::IO, basis::B) where {B<:AbstractRadialBasis}
if basis.poly_deg < 0
print(io, "\n No Monomial augmentation")
else
print(io, "\n Monomial: degree $(basis.poly_deg)")
end
end
9 changes: 2 additions & 7 deletions src/basis/gaussian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ struct Gaussian{T,D<:Int} <: AbstractRadialBasis
if all(ε .< 0)
throw(ArgumentError("Shape parameter should be > 0. (ε=$ε)"))
end
poly_deg < -1 &&
throw(ArgumentError("Augmented Monomial degree must be at least 0 (constant)."))
return new{T,D}(ε, poly_deg)
end
end
Expand Down Expand Up @@ -47,11 +45,8 @@ end
function Base.show(io::IO, rbf::Gaussian)
print(io, "Gaussian, exp(-(ε*r)²)")
print(io, "\n├─Shape factor: ε = $(rbf.ε)")
if rbf.poly_deg < 0
print(io, "\n└─No Monomial augmentation")
else
print(io, "\n└─Polynomial augmentation: degree $(rbf.poly_deg)")
end
print(io, "\n└─Polynomial augmentation: degree $(rbf.poly_deg)")
return nothing
end

print_basis(rbf::Gaussian) = "Gaussian (ε = $(rbf.ε))"
2 changes: 0 additions & 2 deletions src/basis/inverse_multiquadric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ struct IMQ{T,D<:Int} <: AbstractRadialBasis
if all(ε .< 0)
throw(ArgumentError("Shape parameter should be > 0. (ε=$ε)"))
end
poly_deg < -1 &&
throw(ArgumentError("Augmented Monomial degree must be at least 0 (constant)."))
return new{T,D}(ε, poly_deg)
end
end
Expand Down
5 changes: 2 additions & 3 deletions src/interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ function Base.show(io::IO, op::Interpolator)
println(io, "├─Input type: ", typeof(first(op.x)))
println(io, "├─Output type: ", typeof(first(op.y)))
println(io, "├─Number of points: ", length(op.x))
return println(
return print(
io,
"└─Basis: ",
print_basis(op.rbf_basis),
" with degree $(_get_deg(op.monomial_basis)) Monomial",
" with degree $(degree(op.monomial_basis)) Monomial",
)
end
_get_deg(::MonomialBasis{Dim,Deg}) where {Dim,Deg} = Deg
2 changes: 1 addition & 1 deletion src/operators/directional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ function update_weights!(op::RadialBasisOperator{<:Directional})
end

# pretty printing
print_op(op::Directional) = "Directional Gradient (∇f⋅v)"
print_op(op::Directional) = "Directional Derivative (∇f⋅v)"
2 changes: 1 addition & 1 deletion src/operators/laplacian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ function laplacian(
end

# pretty printing
print_op(op::Laplacian) = "Laplacian (∇²f or Δf)"
print_op(op::Laplacian) = "Laplacian (∇²f)"
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ HaltonSequences = "13907d55-377f-55d6-a9d6-25ac19e11b95"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10 changes: 7 additions & 3 deletions test/basis/gaussian.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using RadialBasisFunctions
import RadialBasisFunctions as RBF
using StaticArrays
using StaticArraysCore

@testset "Constructors" begin
@testset "Constructors and Printing" begin
g = Gaussian()
@test g isa Gaussian
@test g.ε == 1
Expand All @@ -13,7 +13,11 @@ using StaticArrays
@test g.poly_deg == 0

@test_throws ArgumentError Gaussian(-1)
@test_throws ArgumentError Gaussian(; poly_deg=-2)

@test repr(g) == """
Gaussian, exp(-(ε*r)²)
├─Shape factor: ε = 5.0
└─Polynomial augmentation: degree 0"""
end

x₁ = SVector(1.0, 2)
Expand Down
10 changes: 7 additions & 3 deletions test/basis/inverse_multiquadric.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using RadialBasisFunctions
import RadialBasisFunctions as RBF
using StaticArrays
using StaticArraysCore

@testset "Constructors" begin
@testset "Constructors and Printing" begin
imq = IMQ()
@test imq isa IMQ
@test imq.ε == 1
Expand All @@ -13,7 +13,11 @@ using StaticArrays
@test imq.poly_deg == 0

@test_throws ArgumentError IMQ(-1)
@test_throws ArgumentError IMQ(; poly_deg=-2)

@test repr(imq) == """
Inverse Multiquadrics, 1/sqrt((r*ε)²+1)
├─Shape factor: ε = 5.0
└─Polynomial augmentation: degree 0"""
end

x₁ = SVector(1.0, 2)
Expand Down
8 changes: 7 additions & 1 deletion test/basis/monomial.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using RadialBasisFunctions
import RadialBasisFunctions as RBF
using StaticArrays
using StaticArraysCore

@testset "Construction and Printing" begin
@test_throws ArgumentError MonomialBasis(1, -1)
m = MonomialBasis(1, 0)
@test repr(m) == "MonomialBasis of degree 0 in 1 dimensions"
end

@testset "dim=1, deg=0" begin
inputs = (SVector(2.0), 2.0)
Expand Down
8 changes: 6 additions & 2 deletions test/basis/polyharmonic_spline.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using RadialBasisFunctions
import RadialBasisFunctions as RBF
using StaticArrays
using StaticArraysCore

@testset "Constructors" begin
@testset "Constructors and Printing" begin
phs = PHS()
@test phs isa PHS3
@test phs.poly_deg == 2
Expand All @@ -12,6 +12,10 @@ using StaticArrays

@test_throws ArgumentError PHS(2; poly_deg=-1)
@test_throws ArgumentError PHS(3; poly_deg=-2)

@test repr(phs) == """
Polyharmonic spline (r⁵)
└─Polynomial augmentation: degree 0"""
end

@testset "PHS, n=1" begin
Expand Down
7 changes: 6 additions & 1 deletion test/operators/directional.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using Statistics
using HaltonSequences
using LinearAlgebra
Expand Down Expand Up @@ -45,3 +45,8 @@ end
exact = map((x, vv) -> SVector(df_dx(x), df_dy(x)) ⋅ vv, x2, v)
@test mean_percent_error(∇v(y), exact) < 10
end

@testset "Printing" begin
∇v = Directional((1, 2), (3, 4))
@test RadialBasisFunctions.print_op(∇v) == "Directional Derivative (∇f⋅v)"
end
7 changes: 6 additions & 1 deletion test/operators/gradient.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using Statistics
using HaltonSequences

Expand Down Expand Up @@ -30,3 +30,8 @@ end
@test mean_percent_error(∇y[1], df_dx.(x2)) < 10
@test mean_percent_error(∇y[2], df_dy.(x2)) < 10
end

@testset "Printing" begin
∇ = Gradient((1, 2))
@test RadialBasisFunctions.print_op(∇) == "Gradient (∇f)"
end
9 changes: 8 additions & 1 deletion test/operators/interpolation.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using HaltonSequences

"""
Expand All @@ -24,3 +24,10 @@ interp = Interpolator(x, y, PHS(3; poly_deg=2))

xnew = SVector(0.5, 0.5)
@test abs(interp(xnew) - franke(xnew)) < 1e-5

@test repr(interp) == """
Interpolator
├─Input type: StaticArraysCore.SVector{2, Float64}
├─Output type: Float64
├─Number of points: 10000
└─Basis: Polyharmonic spline (r³) with degree 2 Monomial"""
7 changes: 6 additions & 1 deletion test/operators/laplacian.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using Statistics
using HaltonSequences

Expand Down Expand Up @@ -31,3 +31,8 @@ end
∇² = laplacian(x, x2, PHS(3; poly_deg=4))
@test mean_percent_error(∇²(y), ∇²f.(x2)) < 10
end

@testset "Printing" begin
∇ = Laplacian(identity)
@test RadialBasisFunctions.print_op(∇) == "Laplacian (∇²f)"
end
5 changes: 5 additions & 0 deletions test/operators/monomial.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using RadialBasisFunctions

@test_throws ArgumentError RadialBasisFunctions.ℒMonomialBasis(1, -1, identity)
m = RadialBasisFunctions.ℒMonomialBasis(1, 0, identity)
@test repr(m) == "ℒMonomialBasis of degree 0 in 1 dimensions"
2 changes: 1 addition & 1 deletion test/operators/operator_algebra.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using LinearAlgebra
using Statistics
using HaltonSequences
Expand Down
7 changes: 6 additions & 1 deletion test/operators/partial.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using Statistics
using HaltonSequences

Expand Down Expand Up @@ -69,3 +69,8 @@ end
@test mean_percent_error(∂x(y), df_dx.(x2)) < 10
@test mean_percent_error(∂y(y), df_dy.(x2)) < 10
end

@testset "Printing" begin
∂ = Partial(identity, 1, 2)
@test RadialBasisFunctions.print_op(∂) == "∂ⁿf/∂xᵢ (n = 1, i = 2)"
end
4 changes: 3 additions & 1 deletion test/operators/regrid.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using Statistics
using HaltonSequences

Expand All @@ -15,3 +15,5 @@ y = f.(x)
x2 = map(x -> SVector{2}(rand(2)), 1:100)
r = regrid(x, x2, PHS(3; poly_deg=2))
@test mean_percent_error(r(y), f.(x2)) < 0.1

@test RadialBasisFunctions.print_op(r.ℒ) == "regrid"
2 changes: 1 addition & 1 deletion test/operators/virtual.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using RadialBasisFunctions
using StaticArrays
using StaticArraysCore
using Statistics
using HaltonSequences

Expand Down
2 changes: 1 addition & 1 deletion test/solve.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using RadialBasisFunctions
import RadialBasisFunctions as RBF
using StaticArrays
using StaticArraysCore
using LinearAlgebra

x = [SVector(1.0, 2.0), SVector(2.0, 1.0), SVector(1.5, 0.0)]
Expand Down