Skip to content

Commit 2fa1b74

Browse files
authored
Powers of negative Laplacians (#32)
* import export * abs power laplacian struct * tests * v0.1
1 parent 8d5657d commit 2fa1b74

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HarmonicOrthogonalPolynomials"
22
uuid = "e416a80e-9640-42f3-8df8-80a93ca01ea5"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.0.5"
4+
version = "0.1"
55

66
[deps]
77
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"

src/HarmonicOrthogonalPolynomials.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module HarmonicOrthogonalPolynomials
22
using FastTransforms, LinearAlgebra, ClassicalOrthogonalPolynomials, ContinuumArrays, DomainSets,
33
BlockArrays, BlockBandedMatrices, InfiniteArrays, StaticArrays, QuasiArrays, Base, SpecialFunctions
4-
import Base: OneTo, axes, getindex, convert, to_indices, _maybetail, tail, eltype, *, ==, ^, copy
4+
import Base: OneTo, axes, getindex, convert, to_indices, _maybetail, tail, eltype, *, ==, ^, copy, -, abs
55
import BlockArrays: block, blockindex, unblock, BlockSlice
66
import DomainSets: indomain
77
import LinearAlgebra: norm, factorize
@@ -12,7 +12,7 @@ import BlockBandedMatrices: BlockRange1
1212
import FastTransforms: Plan, interlace
1313
import QuasiArrays: LazyQuasiMatrix, LazyQuasiArrayStyle
1414

15-
export SphericalHarmonic, UnitSphere, SphericalCoordinate, RadialCoordinate, Block, associatedlegendre, RealSphericalHarmonic, sphericalharmonicy, Laplacian
15+
export SphericalHarmonic, UnitSphere, SphericalCoordinate, RadialCoordinate, Block, associatedlegendre, RealSphericalHarmonic, sphericalharmonicy, Laplacian, AbsLaplacianPower, abs, -, ^
1616

1717
include("multivariateops.jl")
1818
include("spheretrav.jl")

src/laplace.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Laplacian
2+
13
struct Laplacian{T,D} <: LazyQuasiMatrix{T}
24
axis::Inclusion{T,D}
35
end
@@ -13,4 +15,22 @@ copy(D::Laplacian) = Laplacian(copy(D.axis))
1315
@simplify function *::Laplacian, P::AbstractSphericalHarmonic)
1416
# Spherical harmonics are the eigenfunctions of the Laplace operator on the unit sphere
1517
P * Diagonal(mortar(Fill.((-(0:∞)-(0:∞).^2), 1:2:∞)))
16-
end
18+
end
19+
20+
# Negative fractional Laplacian (-Δ)^α or equiv. abs(Δ)^α
21+
22+
struct AbsLaplacianPower{T,D,A} <: LazyQuasiMatrix{T}
23+
axis::Inclusion{T,D}
24+
α::A
25+
end
26+
27+
AbsLaplacianPower{T}(axis::Inclusion{<:Any,D},α) where {T,D} = AbsLaplacianPower{T,D,typeof(α)}(axis,α)
28+
29+
axes(D:: AbsLaplacianPower) = (D.axis, D.axis)
30+
==(a:: AbsLaplacianPower, b:: AbsLaplacianPower) = a.axis == b.axis && a.α == b.α
31+
copy(D:: AbsLaplacianPower) = AbsLaplacianPower(copy(D.axis), D.α)
32+
33+
abs::Laplacian) = AbsLaplacianPower(axes(Δ,1),1)
34+
-::Laplacian) = abs(Δ)
35+
36+
^(D::AbsLaplacianPower, k) = AbsLaplacianPower(D.axis, D.α*k)

test/runtests.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,30 @@ end
374374
@test^2*S*(S\f1.(xyz)))[t] *Δ*S*(S\f1.(xyz)))[t] Δ2_f1(t)
375375
@test^3*S*(S\f1.(xyz)))[t] *Δ*Δ*S*(S\f1.(xyz)))[t] Δ3_f1(t)
376376
end
377+
378+
@testset "abs(Δ)^α - Basics of absolute Laplacian powers" begin
379+
# Set 1
380+
α = 1/3
381+
S = SphericalHarmonic()
382+
Sxyz = axes(S,1)
383+
SΔα = AbsLaplacianPower(Sxyz,α)
384+
Δ = Laplacian(Sxyz)
385+
@test copy(SΔα) == SΔα
386+
@test SΔα isa AbsLaplacianPower
387+
@test SΔα isa QuasiArrays.LazyQuasiMatrix
388+
@test axes(SΔα) == (axes(S,1),axes(S,1))
389+
@test abs(Δ) == -Δ == AbsLaplacianPower(axes(Δ,1),1)
390+
@test abs(Δ)^α == SΔα
391+
# Set 2
392+
α = 7/13
393+
S = SphericalHarmonic()
394+
Sxyz = axes(S,1)
395+
SΔα = AbsLaplacianPower(Sxyz,α)
396+
Δ = Laplacian(Sxyz)
397+
@test copy(SΔα) == SΔα
398+
@test SΔα isa AbsLaplacianPower
399+
@test SΔα isa QuasiArrays.LazyQuasiMatrix
400+
@test axes(SΔα) == (axes(S,1),axes(S,1))
401+
@test abs(Δ) == -Δ == AbsLaplacianPower(axes(Δ,1),1)
402+
@test abs(Δ)^α == SΔα
403+
end

0 commit comments

Comments
 (0)