Skip to content

Commit 59b56c3

Browse files
committed
Increase coverage
1 parent 3b23634 commit 59b56c3

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/bases/bases.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,17 @@ function diff_layout(::AbstractBasisLayout, a, order::Int; dims...)
669669
isone(order) ? diff(a) : diff(diff(a), order-1)
670670
end
671671

672+
function diff_layout(::SubBasisLayout, Vm, order::Int; dims::Integer=1)
673+
dims == 1 || error("not implemented")
674+
diff(parent(Vm), order)[:,parentindices(Vm)[2]]
675+
end
676+
672677
function diff_layout(::SubBasisLayout, Vm, order...; dims::Integer=1)
673678
dims == 1 || error("not implemented")
674679
diff(parent(Vm), order...)[:,parentindices(Vm)[2]]
675680
end
676681

682+
677683
function diff_layout(::WeightedBasisLayout{SubBasisLayout}, Vm, order...; dims::Integer=1)
678684
dims == 1 || error("not implemented")
679685
w = weight(Vm)
@@ -728,6 +734,11 @@ abslaplacian(A, order...; dims...) = abslaplacian_layout(MemoryLayout(A), A, ord
728734
abslaplacian_layout(layout, A, order...; dims...) = abslaplacian_axis(axes(A,1), A, order...; dims...)
729735
abslaplacian_axis(::Inclusion{<:Number}, A, order=1; dims...) = -diff(A, 2order; dims...)
730736

737+
"""
738+
abslaplacian(A, k=1)
739+
740+
computes ``Δ^k * A``.
741+
"""
731742
laplacian(A, order...; dims...) = laplacian_layout(MemoryLayout(A), A, order...; dims...)
732743
laplacian_layout(layout, A, order...; dims...) = laplacian_axis(axes(A,1), A, order...; dims...)
733744
laplacian_axis(::Inclusion{<:Number}, A, order=1; dims...) = diff(A, 2order; dims...)

src/operators.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,5 @@ abs(Δ::Laplacian{T}) where T = AbsLaplacian{T}(axes(Δ,1), Δ.order)
219219
-::Laplacian{<:Any,<:Any,Nothing}) = abs(Δ)
220220
-::AbsLaplacian{T,<:Any,Nothing}) where T = Laplacian{T}.axis)
221221

222-
^::AbsLaplacian{T}, k::Real) where T = AbsLaplacian{T}.axis, operatororder(Δ)*k)
222+
^::AbsLaplacian{T}, k::Real) where T = AbsLaplacian{T}.axis, operatororder(Δ)*k)
223+
^::AbsLaplacian{T}, k::Integer) where T = AbsLaplacian{T}.axis, operatororder(Δ)*k)

test/test_splines.jl

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using ContinuumArrays, LinearAlgebra, Base64, FillArrays, QuasiArrays, BandedMatrices, BlockArrays, Test
22
using QuasiArrays: ApplyQuasiArray, ApplyStyle, MemoryLayout, mul, MulQuasiMatrix, Vec
3-
import LazyArrays: MulStyle, LdivStyle, arguments, applied, apply
3+
import LazyArrays: MulStyle, LdivStyle, arguments, applied, apply, simplifiable
44
import ContinuumArrays: basis, AdjointBasisLayout, ExpansionLayout, BasisLayout, SubBasisLayout, AdjointMappedBasisLayouts, MappedBasisLayout, plan_grid_transform, weaklaplacian
55

66
@testset "Splines" begin
@@ -165,10 +165,27 @@ import ContinuumArrays: basis, AdjointBasisLayout, ExpansionLayout, BasisLayout,
165165
@test typeof(diff(L)) == typeof(diff(L; dims=1)) == typeof(D*L)
166166
@test_throws ErrorException diff(L; dims=2)
167167

168+
@test diff(L[:,1:2])[1.1,:] == diff(L)[1.1,1:2]
169+
168170
@test diff(L,0) L
169171
@test diff(f,0) f
170-
@test diff(L,2)[1.1,:] == laplacian(L)[1.1,:] == -abslaplacian(L)[1.1,:]
171-
@test diff(f,2)[1.1] == laplacian(f)[1.1] == -abslaplacian(f)[1.1]
172+
@test diff(L,2)[1.1,:] == laplacian(L)[1.1,:] == -abslaplacian(L)[1.1,:] == laplacian(L,1)[1.1,:] == -abslaplacian(L,1)[1.1,:]
173+
174+
@test diff(L[:,1:2],2)[1.1,:] == diff(L,2)[1.1,1:2]
175+
@test diff(f,2)[1.1] == laplacian(f)[1.1] == laplacian(f,1)[1.1] == -abslaplacian(f)[1.1] == -abslaplacian(f,1)[1.1]
176+
177+
@test laplacian(L[:,1:2])[1.1,:] == laplacian(L)[1.1,1:2] == -abslaplacian(L[:,1:2])[1.1,:] == -abslaplacian(L)[1.1,1:2]
178+
179+
Δ = Laplacian(L)
180+
@test* L)[1.1,:] == -(abs(Δ) * L)[1.1,:] == laplacian(L)[1.1,:]
181+
@test simplifiable(*, Δ, L) == simplifiable(*, abs(Δ), L) == Val(true)
182+
@test -abs(Δ) == Δ
183+
@test -Δ == abs(Δ)
184+
@test Δ^2 == Δ*Δ
185+
@test abs(Δ)^2 == abs^2) == abs(Δ)^2.0
186+
@test simplifiable(*, Δ, Δ) == simplifiable(*, abs(Δ), abs(Δ)) == Val(true)
187+
@test summary(Δ) == "Laplacian(Inclusion(1 .. 3))"
188+
@test summary^2) == "Laplacian(Inclusion(1 .. 3), 2)"
172189

173190
M = applied(*, (D*L).args..., [1,2,4])
174191
@test eltype(materialize(M)) == Float64

0 commit comments

Comments
 (0)