Skip to content

Commit ee28bd8

Browse files
authored
Weighted(Jacobi(1,1)) -> Ultraspherical(-1/2) for simpler operators (#60)
* Weighted(Jacobi(1,1)) -> Ultraspherical(-1/2) for simpler operators * tests pass * tests pass * fix dirichlet * Update test_dirichlet.jl
1 parent 6b23e0d commit ee28bd8

File tree

8 files changed

+67
-36
lines changed

8 files changed

+67
-36
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PiecewiseOrthogonalPolynomials"
22
uuid = "4461d12d-4663-4550-8580-cb764c85e20f"
33
authors = ["Sheehan Olver <solver@mac.com>"]
4-
version = "0.3"
4+
version = "0.4"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/PiecewiseOrthogonalPolynomials.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import ClassicalOrthogonalPolynomials: grid, plotgrid, ldiv, pad, adaptivetransf
99
import ContinuumArrays: @simplify, factorize, TransformFactorization, AbstractBasisLayout, MemoryLayout, layout_broadcasted, ExpansionLayout, basis, plan_transform, plan_grid_transform, grammatrix, weaklaplacian, MulPlan, InvPlan
1010
import LazyArrays: paddeddata
1111
import LazyBandedMatrices: BlockBroadcastMatrix, BlockVec, BandedLazyLayouts, AbstractLazyBandedBlockBandedLayout, UpperOrLowerTriangular
12-
import Base: size, axes, getindex, +, -, *, /, ==, \, OneTo, oneto, replace_in_print_matrix, copy, diff, getproperty, adjoint, transpose, tail, _sum, inv
12+
import Base: size, axes, getindex, +, -, *, /, ==, \, OneTo, oneto, replace_in_print_matrix, copy, diff, getproperty, adjoint, transpose, tail, _sum, inv, show, summary
1313
import LinearAlgebra: BlasInt
14+
import InfiniteArrays: OneToInf
15+
import FillArrays: AbstractFill
1416
import MatrixFactorizations: reversecholcopy
1517

1618
export PiecewisePolynomial, ContinuousPolynomial, DirichletPolynomial, Derivative, Block, weaklaplacian, grammatrix

src/arrowhead.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ arrowheadlayout(::BandedLazyLayouts) = LazyArrowheadLayout()
112112
symmetriclayout(lay::ArrowheadLayouts) = SymmetricLayout{typeof(lay)}()
113113

114114
MemoryLayout(::Type{<:ArrowheadMatrix{<:Any,<:Any,<:Any,<:Any,<:AbstractVector{D}}}) where D = arrowheadlayout(MemoryLayout(D))
115+
# Hack since ∞ diagonal fill is only DiagonalLayout{FillLayout}
116+
MemoryLayout(::Type{<:ArrowheadMatrix{<:Any,<:Any,<:Any,<:Any,<:AbstractVector{<:Diagonal{<:Any,<:AbstractFill{<:Any,1,<:Tuple{OneToInf}}}}}}) = LazyArrowheadLayout()
115117

116118
sublayout(::ArrowheadLayouts,
117119
::Type{<:NTuple{2,BlockSlice{<:BlockRange{1, Tuple{OneTo{Int}}}}}}) = ArrowheadLayout()

src/continuouspolynomial.jl

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ axes(B::ContinuousPolynomial{0}) = axes(PiecewisePolynomial(B))
1414
axes(B::ContinuousPolynomial{1}) =
1515
(Inclusion(first(B.points) .. last(B.points)), blockedrange(Vcat(length(B.points), Fill(length(B.points) - 1, ∞))))
1616

17+
show(io::IO, Q::ContinuousPolynomial{λ}) where λ = summary(io, Q)
18+
summary(io::IO, Q::ContinuousPolynomial{λ}) where λ = print(io, "ContinuousPolynomial{}($(Q.points))")
19+
1720
==(P::PiecewisePolynomial, C::ContinuousPolynomial{0}) = P == PiecewisePolynomial(C)
1821
==(C::ContinuousPolynomial{0}, P::PiecewisePolynomial) = PiecewisePolynomial(C) == P
1922
==(::PiecewisePolynomial, ::ContinuousPolynomial{1}) = false
@@ -25,6 +28,8 @@ axes(B::ContinuousPolynomial{1}) =
2528

2629
getindex(P::ContinuousPolynomial{0,T}, x::Number, Kk::BlockIndex{1}) where {T} = PiecewisePolynomial(P)[x, Kk]
2730

31+
bubblebasis(::Type{T}) where T = Ultraspherical{T}(-one(real(T))/2)
32+
2833
function getindex(P::ContinuousPolynomial{1,T}, x::Number, Kk::BlockIndex{1}) where {T}
2934
K, k = block(Kk), blockindex(Kk)
3035
if K == Block(1)
@@ -33,7 +38,7 @@ function getindex(P::ContinuousPolynomial{1,T}, x::Number, Kk::BlockIndex{1}) wh
3338
b = searchsortedlast(P.points, x)
3439
if b == k
3540
α, β = convert(T, P.points[b]), convert(T, P.points[b+1])
36-
Weighted(Jacobi{T}(1, 1))[affine.. β, ChebyshevInterval{real(T)}())[x], Int(K)-1]
41+
bubblebasis(T)[affine.. β, ChebyshevInterval{real(T)}())[x], Int(K)+1]
3742
else
3843
zero(T)
3944
end
@@ -66,11 +71,11 @@ end
6671

6772
function plan_transform(C::ContinuousPolynomial{1,T}, Ns::NTuple{N,Block{1}}, dims=ntuple(identity,Val(N))) where {N,T}
6873
P = Legendre{T}()
69-
W = Weighted(Jacobi{T}(1,1))
74+
W = bubblebasis(T)
7075
# TODO: this is unnecessarily not triangular which makes it much slower than necessary and prevents in-place.
7176
# However, the speed of the Legendre transform will far exceed this so its not high priority.
7277
# Probably using Ultraspherical(-1/2) would be better.
73-
= [[T[1 1; -1 1]/2; Zeros{T}(∞,2)] (P \ W)]
78+
= [[T[1 1; -1 1]/2; Zeros{T}(∞,2)] (P \ W)[:,3:end]]
7479
ContinuousPolynomialTransform(plan_transform(ContinuousPolynomial{0}(C), Ns .+ 1, dims).F,
7580
InvPlan(map(N -> R̃[1:Int(N),1:Int(N)], Ns .+ 1), _doubledims(dims...)),
7681
dims)
@@ -167,11 +172,11 @@ function adaptivetransform_ldiv(Q::ContinuousPolynomial{1,V}, f::AbstractQuasiVe
167172
= paddeddata(c)
168173
N = max(2,div(length(c̃), M, RoundUp)) # degree
169174
P = Legendre{T}()
170-
W = Weighted(Jacobi{T}(1,1))
175+
W = bubblebasis(T)
171176

172177
# Restrict hat function to each element, add in bubble functions and compute connection
173178
# matrix to Legendre. [1 1; -1 1]/2 are the Legendre coefficients of the hat functions.
174-
= [[T[1 1; -1 1]/2; Zeros{T}(∞,2)] (P \ W)]
179+
= [[T[1 1; -1 1]/2; Zeros{T}(∞,2)] (P \ W)[:,3:end]]
175180

176181
# convert from Legendre to piecewise restricted hat + Bubble
177182
dat = R̃[1:N,1:N] \ reshape(pad(c̃, M*N), M, N)'
@@ -200,7 +205,7 @@ grid(P::ContinuousPolynomial{1}, M::Block{1}) = grid(ContinuousPolynomial{0}(P),
200205
function \(P::ContinuousPolynomial{0}, C::ContinuousPolynomial{1})
201206
T = promote_type(eltype(P), eltype(C))
202207
@assert P.points == C.points
203-
v = (convert(T, 2):2:) ./ (3:2:∞)
208+
v = one(T) ./ (3:2:∞)
204209
N = length(P.points)
205210
ArrowheadMatrix(_BandedMatrix(Ones{T}(2, N)/2, oneto(N-1), 0, 1),
206211
(_BandedMatrix(Fill(v[1], 1, N-1), oneto(N-1), 0, 0),),
@@ -234,15 +239,15 @@ function grammatrix(C::ContinuousPolynomial{1, T, <:AbstractRange}) where T
234239

235240
N = length(r) - 1
236241
h = step(r) # 2/N
237-
a = ((convert(T,4):4:∞) .* (convert(T,-2):2:∞)) ./ ((1:2:∞) .* (3:2:∞) .* (-1:2:∞))
238-
b = (((convert(T,2):2:∞) ./ (3:2:∞)).^2 .* (convert(T,2) ./ (1:2:∞) .+ convert(T,2) ./ (5:2:∞)))
242+
a = [-2 /((2k+1)*(2k+3)*(2k+5)) for k = -1:∞]
243+
b = [4 /((2k+1)*(2k+3)*(2k+5)) for k = 0:∞]
239244

240245
a11 = LazyBandedMatrices.Bidiagonal(Vcat(h/3, Fill(2h/3, N-1), h/3), Fill(h/6, N), :U)
241-
a21 = _BandedMatrix(Fill(h/3, 2, N), N+1, 1, 0)
242-
a31 = _BandedMatrix(Vcat(Fill(-2h/15, 1, N), Fill(2h/15, 1, N)), N+1, 1, 0)
246+
a21 = _BandedMatrix(Fill(h/6, 2, N), N+1, 1, 0)
247+
a31 = _BandedMatrix(Vcat(Fill(-h/30, 1, N), Fill(h/30, 1, N)), N+1, 1, 0)
243248

244249
Symmetric(ArrowheadMatrix(a11, (a21, a31), (),
245-
Fill(_BandedMatrix(Vcat((-h*a/2)',
250+
Fill(_BandedMatrix(Vcat((h*a/2)',
246251
Zeros{T}(1,∞),
247252
(h*b/2)'), ∞, 0, 2), N)))
248253
end
@@ -278,12 +283,17 @@ function diff(C::ContinuousPolynomial{1,T}; dims=1) where T
278283
r = C.points
279284
N = length(r)
280285
s = one(T) ./ (r[2:end]-r[1:end-1])
281-
v = mortar(Fill(T(2) * s, ∞)) .* mortar(Fill.((-convert(T, 2):-2:-∞), N - 1))
282-
z = Zeros{T}(axes(v))
283-
H = BlockBroadcastArray(hcat, z, v)
284-
M = BlockVcat(Hcat(Ones{T}(N) .* [zero(T); s] , -Ones{T}(N) .* [s; zero(T)] ), H)
285-
P = ContinuousPolynomial{0}(C)
286-
ApplyQuasiMatrix(*, P, _BandedBlockBandedMatrix(M', axes(P, 2), (0, 0), (0, 1)))
286+
ContinuousPolynomial{0}(r) * ArrowheadMatrix(_BandedMatrix(Vcat([0; s]', [-s; 0]'), length(s), 0, 1), (), (),
287+
(-2s) .* Ref(Eye{T}(∞)))
288+
end
289+
290+
function diff(C::ContinuousPolynomial{1,T,<:AbstractRange}; dims=1) where T
291+
# Legendre() \ (D*Weighted(Jacobi(1,1)))
292+
r = C.points
293+
N = length(r)
294+
s = 1 ./ step(r)
295+
ContinuousPolynomial{0}(r) * ArrowheadMatrix(_BandedMatrix(Vcat(Fill(s, 1, N), Fill(-s, 1, N)), N-1, 0, 1), (), (),
296+
Fill(-2s*Eye{T}(∞), N-1))
287297
end
288298

289299
function weaklaplacian(C::ContinuousPolynomial{1,T,<:AbstractRange}) where T
@@ -294,7 +304,7 @@ function weaklaplacian(C::ContinuousPolynomial{1,T,<:AbstractRange}) where T
294304
t1 = Vcat(-si, Fill(-2si, N-2), -si)
295305
t2 = Fill(si, N-1)
296306
Symmetric(ArrowheadMatrix(LazyBandedMatrices.Bidiagonal(t1, t2, :U), (), (),
297-
Fill(Diagonal(convert(T, -16) .* (1:∞) .^ 2 ./ (s .* ((2:2:) .+ 1))), N-1)))
307+
Fill(Diagonal(convert(T,-4) ./ (s*(convert(T,3):2:∞))), N-1)))
298308
end
299309

300310

src/dirichlet.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ PiecewisePolynomial(P::DirichletPolynomial{T}) where {T} = PiecewisePolynomial(C
1111

1212
axes(B::DirichletPolynomial) = (Inclusion(first(B.points) .. last(B.points)), blockedrange(Vcat(length(B.points)-2, Fill(length(B.points) - 1, ∞))))
1313

14+
show(io::IO, Q::DirichletPolynomial) = summary(io, Q)
15+
summary(io::IO, Q::DirichletPolynomial) = print(io, "DirichletPolynomial($(Q.points))")
16+
17+
1418
==(P::DirichletPolynomial, C::DirichletPolynomial) = P.points == C.points
1519
==(P::PiecewisePolynomial, C::DirichletPolynomial) = false
1620
==(C::DirichletPolynomial, P::PiecewisePolynomial) = false
@@ -170,23 +174,23 @@ function weaklaplacian(C::DirichletPolynomial{T,<:AbstractRange}) where T
170174
t1 = Fill(-2si, N-2)
171175
t2 = Fill(si, N-3)
172176
Symmetric(ArrowheadMatrix(LazyBandedMatrices.Bidiagonal(t1, t2, :U), (), (),
173-
Fill(Diagonal(convert(T, -16) .* (1:∞) .^ 2 ./ (s .* ((2:2:) .+ 1))), N-1)))
177+
Fill(Diagonal(convert(T, -4) ./ (s*(convert(T,3):2:∞))), N-1)))
174178
end
175179

176180
function grammatrix(Q::DirichletPolynomial{T, <:AbstractRange}) where T
177181
r = Q.points
178182

179183
N = length(r) - 1
180184
h = step(r) # 2/N
181-
a = ((convert(T,4):4:∞) .* (convert(T,-2):2:∞)) ./ ((1:2:∞) .* (3:2:∞) .* (-1:2:∞))
182-
b = (((convert(T,2):2:∞) ./ (3:2:∞)).^2 .* (convert(T,2) ./ (1:2:∞) .+ convert(T,2) ./ (5:2:∞)))
185+
a = [-2 /((2k+1)*(2k+3)*(2k+5)) for k = -1:∞]
186+
b = [4 /((2k+1)*(2k+3)*(2k+5)) for k = 0:∞]
183187

184188
a11 = LazyBandedMatrices.Bidiagonal(Fill(2h/3, N-1), Fill(h/6, N-2), :U)
185-
a21 = _BandedMatrix(Fill(h/3, 2, N), N-1, 0, 1)
186-
a31 = _BandedMatrix(Vcat(Fill(-2h/15, 1, N), Fill(2h/15, 1, N)), N-1, 0, 1)
189+
a21 = _BandedMatrix(Fill(h/6, 2, N), N-1, 0, 1)
190+
a31 = _BandedMatrix(Vcat(Fill(-h/30, 1, N), Fill(h/30, 1, N)), N-1, 0, 1)
187191

188192
Symmetric(ArrowheadMatrix(a11, (a21, a31), (),
189-
Fill(_BandedMatrix(Vcat((-h*a/2)',
193+
Fill(_BandedMatrix(Vcat((h*a/2)',
190194
Zeros{T}(1,∞),
191195
(h*b/2)'), ∞, 0, 2), N)))
192196
end

test/test_arrowhead.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Base: oneto, OneTo
88
@testset "ArrowheadMatrix" begin
99
@testset "Algebra" begin
1010
n = 4; p = 5;
11-
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
11+
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
1212
ntuple(_ -> BandedMatrix((0 => randn(n-1), -1 => randn(n-1)), (n,n-1)), 2),
1313
ntuple(_ -> BandedMatrix((0 => randn(n), 1 => randn(n-1)), (n-1,n)), 3),
1414
fill(BandedMatrix((0 => randn(p) .+ 10, 2 => randn(p-2), -1=> randn(p-1)), (p, p)), n-1))
@@ -30,7 +30,7 @@ import Base: oneto, OneTo
3030

3131
@testset "mul" begin
3232
n = 4; p = 5;
33-
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
33+
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
3434
ntuple(_ -> BandedMatrix((0 => randn(n-1), -1 => randn(n-1)), (n,n-1)), 2),
3535
ntuple(_ -> BandedMatrix((0 => randn(n), 1 => randn(n-1)), (n-1,n)), 3),
3636
fill(BandedMatrix((0 => randn(p) .+ 10, 2 => randn(p-2), -1=> randn(p-1)), (p, p)), n-1))
@@ -47,7 +47,7 @@ import Base: oneto, OneTo
4747

4848
@testset "UpperTriangular" begin
4949
n = 4; p = 5;
50-
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
50+
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
5151
[BandedMatrix((0 => randn(n-1), -1 => randn(n-1)), (n,n-1)) for _=1:2],
5252
[BandedMatrix((0 => randn(n), 1 => randn(n-1)), (n-1,n)) for _=1:2],
5353
fill(BandedMatrix((0 => randn(p) .+ 10, 2 => randn(p-2), -1=> randn(p-1)), (p, p)), n-1))
@@ -74,15 +74,15 @@ import Base: oneto, OneTo
7474

7575
@testset "reversecholesky" begin
7676
n = 3; p = 5;
77-
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
77+
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
7878
[BandedMatrix((0 => randn(n-1), -1 => randn(n-1)), (n,n-1)) for _=1:2],
7979
BandedMatrix{Float64, Matrix{Float64}, OneTo{Int}}[],
8080
fill(BandedMatrix((0 => randn(p) .+ 10, 2 => randn(p-2)), (p, p)), n-1))
8181

8282
@test reversecholesky(Symmetric(Matrix(A))).U reversecholesky!(Symmetric(copy(A))).U
8383

8484

85-
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
85+
A = ArrowheadMatrix(BandedMatrix(0 => randn(n) .+ 10, 1 => randn(n-1), -1 => randn(n-1)),
8686
[BandedMatrix((0 => randn(n-1), -1 => randn(n-1)), (n,n-1)) for _=1:2],
8787
BandedMatrix{Float64, Matrix{Float64}, OneTo{Int}}[],
8888
fill(BandedMatrix((0 => randn(p) .+ 10, 1 => randn(p-1), 2 => randn(p-2)), (p, p)), n-1))
@@ -103,7 +103,7 @@ import Base: oneto, OneTo
103103
@test blockbandwidths(L) == (1,1)
104104
@test subblockbandwidths(L) == (1,1)
105105

106-
@test stringmime("text/plain", L[Block.(OneTo(3)), Block.(OneTo(3))]) == "3×3-blocked 9×10 ArrowheadMatrix{Float64}:\n 0.5 0.5 ⋅ ⋅ │ 0.666667 ⋅ ⋅ │ ⋅ ⋅ ⋅ \n ⋅ 0.5 0.5 ⋅ │ ⋅ 0.666667 ⋅ │ ⋅ ⋅ ⋅ \n ⋅ ⋅ 0.5 0.5 │ ⋅ ⋅ 0.666667 │ ⋅ ⋅ ⋅ \n ───────────────────────┼───────────────────────────────────┼───────────────\n -0.5 0.5 ⋅ ⋅ │ 0.0 ⋅ ⋅ │ 0.8 ⋅ ⋅ \n ⋅ -0.5 0.5 ⋅ │ ⋅ 0.0 ⋅ │ ⋅ 0.8 ⋅ \n ⋅ ⋅ -0.5 0.5 │ ⋅ ⋅ 0.0 │ ⋅ ⋅ 0.8\n ───────────────────────┼───────────────────────────────────┼───────────────\n ⋅ ⋅ ⋅ ⋅ │ -0.666667 ⋅ ⋅ │ 0.0 ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ │ ⋅ -0.666667 ⋅ │ ⋅ 0.0 ⋅ \n ⋅ ⋅ ⋅ ⋅ │ ⋅ ⋅ -0.666667 │ ⋅ ⋅ 0.0"
106+
@test stringmime("text/plain", L[Block.(OneTo(3)), Block.(OneTo(3))]) == "3×3-blocked 9×10 ArrowheadMatrix{Float64}:\n 0.5 0.5 ⋅ ⋅ │ 0.333333 ⋅ ⋅ │ ⋅ ⋅ ⋅ \n ⋅ 0.5 0.5 ⋅ │ ⋅ 0.333333 ⋅ │ ⋅ ⋅ ⋅ \n ⋅ ⋅ 0.5 0.5 │ ⋅ ⋅ 0.333333 │ ⋅ ⋅ ⋅ \n ───────────────────────┼───────────────────────────────────┼───────────────\n -0.5 0.5 ⋅ ⋅ │ 0.0 ⋅ ⋅ │ 0.2 ⋅ ⋅ \n ⋅ -0.5 0.5 ⋅ │ ⋅ 0.0 ⋅ │ ⋅ 0.2 ⋅ \n ⋅ ⋅ -0.5 0.5 │ ⋅ ⋅ 0.0 │ ⋅ ⋅ 0.2\n ───────────────────────┼───────────────────────────────────┼───────────────\n ⋅ ⋅ ⋅ ⋅ │ -0.333333 ⋅ ⋅ │ 0.0 ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ │ ⋅ -0.333333 ⋅ │ ⋅ 0.0 ⋅ \n ⋅ ⋅ ⋅ ⋅ │ ⋅ ⋅ -0.333333 │ ⋅ ⋅ 0.0"
107107
end
108108

109109
@testset "Helmholtz solve" begin
@@ -128,7 +128,7 @@ import Base: oneto, OneTo
128128

129129
@testset "Dirichlet" begin
130130
n = 5; p = 5;
131-
A = ArrowheadMatrix(BandedMatrix(0 => randn(n-2) .+ 10, 1 => randn(n-3), -1 => randn(n-3)),
131+
A = ArrowheadMatrix(BandedMatrix(0 => randn(n-2) .+ 10, 1 => randn(n-3), -1 => randn(n-3)),
132132
[BandedMatrix((0 => randn(n-2), 1 => randn(n-2)), (n-2,n-1)) for _=1:2],
133133
BandedMatrix{Float64, Matrix{Float64}, OneTo{Int}}[],
134134
fill(BandedMatrix((0 => randn(p) .+ 10, 2 => randn(p-2)), (p, p)), n-1))

test/test_continuouspolynomial.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ using ContinuumArrays: plan_grid_transform
6161
JR = Block.(1:10)
6262
KR = Block.(1:11)
6363
R = P\C
64+
@test P[0.1,1:10]'*R[1:10,1:10] C[0.1,1:10]'
6465
@test R[KR,JR]'*((P'P)[KR,KR]*R[KR,JR]) (C'C)[JR,JR]
6566
@test (P'C)[JR,JR] (C'P)[JR,JR]'
6667
end
@@ -87,6 +88,8 @@ using ContinuumArrays: plan_grid_transform
8788
D = Derivative(x)
8889
A = P\D*C
8990

91+
@test (D*expand(C, exp))[0.1] exp(0.1)
92+
9093
xx = rand(5)
9194
c = (x, p) -> ContinuousPolynomial{1, eltype(x)}(r)[x, p]
9295

@@ -147,7 +150,7 @@ using ContinuumArrays: plan_grid_transform
147150
x = SVector(0.1, 0.2)
148151
@test view(C, x, 1) .* view(C, x, 1) C[x,1] .* C[x,1]
149152

150-
@test C \ (C[:,1] .* C[:,1]) [1; zeros(3); -1/4; zeros(∞)]
153+
@test C \ (C[:,1] .* C[:,1]) [1; zeros(3); -1/2; zeros(∞)]
151154
@test C \ (C[:,1] .* C[:,3]) zeros(∞)
152155
end
153156

@@ -158,8 +161,8 @@ using ContinuumArrays: plan_grid_transform
158161
x = axes(P,1)
159162
D = Derivative(x)
160163

161-
a = expand(P, x -> abs(x)  1/3 ? 2 : 3)
162-
L = (D*C)'* (a .* (D*C))
164+
a = expand(P, x -> abs(x)  1/3 ? 2 : 3)
165+
L = (D*C)'* (a .* (D*C))
163166
end
164167

165168
@testset "expand" begin

test/test_dirichlet.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,14 @@ using PiecewiseOrthogonalPolynomials: ArrowheadMatrix, plan_grid_transform
6969
@test Q[0.1, Block.(1:20)]' * V * Q[0.2,Block.(1:21)] f(0.1,0.2)
7070
@test F \ V vals
7171
end
72+
73+
@testset "show" begin
74+
Q = DirichletPolynomial(-1:1)
75+
C = ContinuousPolynomial{1}(-1:1)
76+
P = ContinuousPolynomial{0}(-1:1)
77+
78+
@test sprint(show, Q) == "DirichletPolynomial(-1:1)"
79+
@test sprint(show, C) == "ContinuousPolynomial{1}(-1:1)"
80+
@test sprint(show, P) == "ContinuousPolynomial{0}(-1:1)"
81+
end
7282
end

0 commit comments

Comments
 (0)