Skip to content

Commit 6c01961

Browse files
committed
PartialDerivative -> diff
1 parent 5b4763f commit 6c01961

File tree

9 files changed

+42
-54
lines changed

9 files changed

+42
-54
lines changed

Project.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "MultivariateOrthogonalPolynomials"
22
uuid = "4f6956fd-4f93-5457-9149-7bfc4b2ce06d"
3-
version = "0.8"
3+
version = "0.9"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -29,17 +29,17 @@ ArrayLayouts = "1.0.9"
2929
BandedMatrices = "1"
3030
BlockArrays = "1.0"
3131
BlockBandedMatrices = "0.13"
32-
ClassicalOrthogonalPolynomials = "0.14.1"
33-
ContinuumArrays = "0.18"
32+
ClassicalOrthogonalPolynomials = "0.15"
33+
ContinuumArrays = "0.19"
3434
DomainSets = "0.7"
3535
FastTransforms = "0.17"
3636
FillArrays = "1.0"
37-
HarmonicOrthogonalPolynomials = "0.6.3"
37+
HarmonicOrthogonalPolynomials = "0.7"
3838
InfiniteArrays = "0.15"
3939
InfiniteLinearAlgebra = "0.9"
4040
LazyArrays = "2.3.1"
4141
LazyBandedMatrices = "0.11.1"
42-
QuasiArrays = "0.11"
42+
QuasiArrays = "0.12"
4343
RecurrenceRelationships = "0.2"
4444
SpecialFunctions = "1, 2"
4545
StaticArrays = "1"

src/MultivariateOrthogonalPolynomials.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import InfiniteArrays: InfiniteCardinal, OneToInf
2323

2424
import ClassicalOrthogonalPolynomials: jacobimatrix, Weighted, orthogonalityweight, HalfWeighted, WeightedBasis, pad, recurrencecoefficients, clenshaw, weightedgrammatrix, Clenshaw
2525
import HarmonicOrthogonalPolynomials: BivariateOrthogonalPolynomial, MultivariateOrthogonalPolynomial, Plan,
26-
PartialDerivative, AngularMomentum, BlockOneTo, BlockRange1, interlace,
26+
AngularMomentum, BlockOneTo, BlockRange1, interlace,
2727
MultivariateOPLayout, AbstractMultivariateOPLayout, MAX_PLOT_BLOCKS
2828

2929
export MultivariateOrthogonalPolynomial, BivariateOrthogonalPolynomial,
3030
UnitTriangle, UnitDisk,
3131
JacobiTriangle, TriangleWeight, WeightedTriangle,
3232
DunklXuDisk, DunklXuDiskWeight, WeightedDunklXuDisk,
3333
Zernike, ZernikeWeight, zerniker, zernikez,
34-
PartialDerivative, Laplacian, AbsLaplacianPower, AngularMomentum,
34+
Laplacian, AbsLaplacianPower, AngularMomentum,
3535
RadialCoordinate, Weighted, Block, jacobimatrix, KronPolynomial, RectPolynomial,
3636
grammatrix, oneto
3737

src/disk.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,14 @@ plan_transform(Z::Zernike{T}, (N,)::Tuple{Block{1}}, dims=1) where T = ZernikeTr
262262
# Laplacian
263263
###
264264

265-
@simplify function *::Laplacian, WZ::Weighted{<:Any,<:Zernike})
265+
function laplacian(WZ::Weighted{T,<:Zernike}; dims...) where T
266266
@assert WZ.P.a == 0 && WZ.P.b == 1
267-
T = eltype(eltype(WZ))
268267
WZ.P * ModalInterlace{T}(broadcast(k -> Diagonal(-cumsum(k:8:∞)), 4:4:∞), (ℵ₀,ℵ₀), (0,0))
269268
end
270269

271-
@simplify function *::Laplacian, Z::Zernike)
270+
function laplacian(Z::Zernike{T}; dims...) where T
272271
a,b = Z.a,Z.b
273272
@assert a == 0
274-
T = promote_type(eltype(eltype(Δ)),eltype(Z)) # TODO: remove extra eltype
275273
D = Derivative(Inclusion(ChebyshevInterval{T}()))
276274
Δs = BroadcastVector{AbstractMatrix{T}}((C,B,A) -> 4(HalfWeighted{:b}(C)\(D*HalfWeighted{:b}(B)))*(B\(D*A)), Normalized.(Jacobi.(b+2,a:∞)), Normalized.(Jacobi.(b+1,(a+1):∞)), Normalized.(Jacobi.(b,a:∞)))
277275
Δ = ModalInterlace(Δs, (ℵ₀,ℵ₀), (-2,2))

src/rect.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,11 @@ function jacobimatrix(::Val{2}, P::RectPolynomial)
5252
Y = jacobimatrix(B)
5353
KronTrav(Y, Eye{eltype(Y)}(∞))
5454
end
55-
@simplify function *(Dx::PartialDerivative{1}, P::RectPolynomial)
56-
A,B = P.args
57-
U,M = (Derivative(axes(A,1))*A).args
58-
# We want I ⊗ D² as A ⊗ B means B * X * A'
59-
RectPolynomial(U,B) * KronTrav(Eye{eltype(M)}(∞), M)
55+
function diff(P::KronPolynomial{N}, order::NTuple{N,Int}; dims...) where N
56+
diffs = diff.(P.args, order)
57+
RectPolynomial(basis.(diffs)...) * KronTrav(coefficients.(diffs)...)
6058
end
6159

62-
@simplify function *(Dx::PartialDerivative{2}, P::RectPolynomial)
63-
A,B = P.args
64-
U,M = (Derivative(axes(B,1))*B).args
65-
RectPolynomial(A,U) * KronTrav(M, Eye{eltype(M)}(∞))
66-
end
6760

6861
function weaklaplacian(P::RectPolynomial)
6962
A,B = P.args

src/rectdisk.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const WeightedDunklXuDisk{T} = WeightedBasis{T,<:DunklXuDiskWeight,<:DunklXuDisk
4141

4242
WeightedDunklXuDisk(β) = DunklXuDiskWeight(β) .* DunklXuDisk(β)
4343

44-
@simplify function *(Dx::PartialDerivative{1}, P::DunklXuDisk)
45-
β = P.β
44+
function diff(::DunklXuDisk, ::Val{(1,0)}; dims=1)
45+
@assert dims == 1
4646
n = mortar(Fill.(oneto(∞),oneto(∞)))
4747
k = mortar(Base.OneTo.(oneto(∞)))
4848
dat = BlockBroadcastArray(hcat,
@@ -53,14 +53,15 @@ WeightedDunklXuDisk(β) = DunklXuDiskWeight(β) .* DunklXuDisk(β)
5353
DunklXuDisk+1) * _BandedBlockBandedMatrix(dat', axes(k,1), (-1,1), (0,2))
5454
end
5555

56-
@simplify function *(Dy::PartialDerivative{2}, P::DunklXuDisk)
56+
function diff(::DunklXuDisk{T}, ::Val{(0,1)}; dims=1) where T
57+
@assert dims == 1
5758
β = P.β
5859
k = mortar(Base.OneTo.(oneto(∞)))
59-
T = promote_type(eltype(Dy), eltype(P)) # avoid bug in convert
6060
DunklXuDisk+1) * _BandedBlockBandedMatrix(((k .+ T(2β)) ./ 2)', axes(k,1), (-1,1), (-1,1))
6161
end
6262

63-
@simplify function *(Dx::PartialDerivative{1}, w_P::WeightedDunklXuDisk)
63+
function diff(w_P::WeightedDunklXuDisk, ::Val{(1,0)}; dims=1)
64+
@assert dims == 1
6465
wP, P = w_P.args
6566
@assert P.β == wP.β
6667
β = P.β
@@ -74,11 +75,11 @@ end
7475
WeightedDunklXuDisk-1) * _BandedBlockBandedMatrix(dat', axes(k,1), (1,-1), (2,0))
7576
end
7677

77-
@simplify function *(Dy::PartialDerivative{2}, w_P::WeightedDunklXuDisk)
78+
function diff(w_P::WeightedDunklXuDisk{T}, ::Val{(0,1)}; dims=1) where T
79+
@assert dims == 1
7880
wP, P = w_P.args
7981
@assert P.β == wP.β
8082
k = mortar(Base.OneTo.(oneto(∞)))
81-
T = promote_type(eltype(Dy), eltype(P)) # avoid bug in convert
8283
WeightedDunklXuDisk(P.β-1) * _BandedBlockBandedMatrix((T(-2).*k)', axes(k,1), (1,-1), (1,-1))
8384
end
8485

src/triangle.jl

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ summary(io::IO, P::TriangleWeight) = print(io, "x^$(P.a)*y^$(P.b)*(1-x-y)^$(P.c)
147147

148148
orthogonalityweight(P::JacobiTriangle) = TriangleWeight(P.a, P.b, P.c)
149149

150-
@simplify function *(Dx::PartialDerivative{1}, P::JacobiTriangle)
150+
function diff(w_P::JacobiTriangle{T}, ::Val{(1,0)}; dims=1) where T
151+
@assert dims == 1
151152
a,b,c = P.a,P.b,P.c
152153
n = mortar(Fill.(oneto(∞),oneto(∞)))
153154
k = mortar(Base.OneTo.(oneto(∞)))
@@ -158,15 +159,16 @@ orthogonalityweight(P::JacobiTriangle) = TriangleWeight(P.a, P.b, P.c)
158159
JacobiTriangle(a+1,b,c+1) * _BandedBlockBandedMatrix(dat', axes(k,1), (-1,1), (0,1))
159160
end
160161

161-
@simplify function *(Dy::PartialDerivative{2}, P::JacobiTriangle)
162+
function diff(w_P::JacobiTriangle{T}, ::Val{(0,1)}; dims=1) where T
163+
@assert dims == 1
162164
a,b,c = P.a,P.b,P.c
163165
k = mortar(Base.OneTo.(oneto(∞)))
164-
T = promote_type(eltype(Dy), eltype(P)) # avoid bug in convert
165166
JacobiTriangle(a,b+1,c+1) * _BandedBlockBandedMatrix((k .+ convert(T, b+c))', axes(k,1), (-1,1), (-1,1))
166167
end
167168

168169
# TODO: The derivatives below only hold for a, b, c > 0.
169-
@simplify function *(Dx::PartialDerivative{1}, P::WeightedTriangle)
170+
function diff(w_P::WeightedTriangle{T}, ::Val{(1,0)}; dims=1) where T
171+
@assert dims == 1
170172
a, b, c = P.P.a, P.P.b, P.P.c
171173
n = mortar(Fill.(oneto(∞),oneto(∞)))
172174
k = mortar(Base.OneTo.(oneto(∞)))
@@ -177,19 +179,13 @@ end
177179
WeightedTriangle(a-1, b, c-1) * _BandedBlockBandedMatrix(dat', axes(k, 1), (1, -1), (1, 0))
178180
end
179181

180-
@simplify function *(Dy::PartialDerivative{2}, P::WeightedTriangle)
182+
function diff(w_P::WeightedTriangle{T}, ::Val{(0,1)}; dims=1) where T
183+
@assert dims == 1
181184
a, b, c = P.P.a, P.P.b, P.P.c
182185
k = mortar(Base.OneTo.(oneto(∞)))
183-
T = promote_type(eltype(Dy), eltype(P)) # avoid bug in convert
184186
WeightedTriangle(a, b-1, c-1) * _BandedBlockBandedMatrix(-one(T) * k', axes(k, 1), (1, -1), (1, -1))
185187
end
186188

187-
# @simplify function *(Δ::Laplacian, P)
188-
# _lap_mul(P, eltype(axes(P,1)))
189-
# end
190-
191-
192-
193189
function grammatrix(A::JacobiTriangle)
194190
@assert A == JacobiTriangle()
195191
n = mortar(Fill.(oneto(∞),oneto(∞)))

test/test_rect.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ using Base: oneto
7979
= RectPolynomial(U, U)
8080
= RectPolynomial(C, C)
8181
𝐱 = axes(T²,1)
82-
D_x,D_y = PartialDerivative{1}(𝐱),PartialDerivative{2}(𝐱)
82+
D_x,D_y = Derivative(𝐱,(1,0)),Derivative(𝐱,(0,1))
8383
D_x*
8484
D_y*
8585
\D_x*
@@ -103,7 +103,7 @@ using Base: oneto
103103

104104
@testset "strong form" begin
105105
𝐱 = axes(W²,1)
106-
D_x,D_y = PartialDerivative{1}(𝐱),PartialDerivative{2}(𝐱)
106+
D_x,D_y = Derivative(𝐱,(1,0)),Derivative{2}(𝐱,(0,1))
107107
Δ =\(D_x^2 + D_y^2)*
108108

109109
K = Block.(1:200); @time L = Δ[K,K]; @time qr(L);

test/test_rectdisk.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import MultivariateOrthogonalPolynomials: dunklxu_raising, dunklxu_lowering, Ang
3939

4040
@test (DunklXuDisk() \ WeightedDunklXuDisk(1.0))[Block.(1:N), Block.(1:N)] (WeightedDunklXuDisk(0.0) \ WeightedDunklXuDisk(1.0))[Block.(1:N), Block.(1:N)]
4141

42-
∂x = PartialDerivative{1}(axes(P, 1))
43-
∂y = PartialDerivative{2}(axes(P, 1))
42+
∂x = Derivative(axes(P, 1), (1,0))
43+
∂y = Derivative(axes(P, 1), (0,1))
4444

4545
Dx = Q \ (∂x * P)
4646
Dy = Q \ (∂y * P)
@@ -67,8 +67,8 @@ import MultivariateOrthogonalPolynomials: dunklxu_raising, dunklxu_lowering, Ang
6767
@test A[Block.(1:N), Block.(1:N)] C
6868
@test A2[Block.(1:N), Block.(1:N)] (A^2)[Block.(1:N), Block.(1:N)] A[Block.(1:N), Block.(1:N)]^2
6969

70-
∂x = PartialDerivative{1}(axes(WQ, 1))
71-
∂y = PartialDerivative{2}(axes(WQ, 1))
70+
∂x = Derivative(axes(WQ, 1), (1,0))
71+
∂y = Derivative(axes(WQ, 1), (0,1))
7272

7373
wDx = WP \ (∂x * WQ)
7474
wDy = WP \ (∂y * WQ)

test/test_triangle.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ import MultivariateOrthogonalPolynomials: tri_forwardrecurrence, grid, TriangleR
135135
P = JacobiTriangle()
136136
𝐱 = axes(P,1)
137137

138-
∂ˣ = PartialDerivative{1}(𝐱)
139-
∂ʸ = PartialDerivative{2}(𝐱)
138+
∂ˣ = Derivative(𝐱, (1,0))
139+
∂ʸ = Derivative(𝐱, (0,1))
140140

141141
@test eltype(∂ˣ) == eltype(∂ʸ) == Float64
142142

@@ -467,8 +467,8 @@ import MultivariateOrthogonalPolynomials: tri_forwardrecurrence, grid, TriangleR
467467
= JacobiTriangle(1,1,1)
468468
𝐱 = axes(P,1)
469469
x,y = first.(𝐱),last.(𝐱)
470-
∂ˣ = PartialDerivative{1}(𝐱)
471-
∂ʸ = PartialDerivative{2}(𝐱)
470+
∂ˣ = Derivative(𝐱, (1,0))
471+
∂ʸ = Derivative(𝐱, (0,1))
472472
L1 = x .* ∂ʸ
473473
L2 = y .* ∂ˣ
474474
L = x .* ∂ʸ - y .* ∂ˣ
@@ -518,8 +518,8 @@ import MultivariateOrthogonalPolynomials: tri_forwardrecurrence, grid, TriangleR
518518
P = Weighted(JacobiTriangle(a, b, c))
519519
Pf = expand(P, f)
520520
𝐱 = axes(P, 1)
521-
∂ˣ = PartialDerivative{1}(𝐱)
522-
∂ʸ = PartialDerivative{2}(𝐱)
521+
∂ˣ = Derivative(𝐱, (1,0))
522+
∂ʸ = Derivative(𝐱, (0,1))
523523
Pfx = ∂ˣ * Pf
524524
Pfy = ∂ʸ * Pf
525525

@@ -579,8 +579,8 @@ import MultivariateOrthogonalPolynomials: tri_forwardrecurrence, grid, TriangleR
579579
P = JacobiTriangle()
580580
W = Weighted(JacobiTriangle(1,1,1))
581581
𝐱 = axes(W,1)
582-
∂_x = PartialDerivative{1}(𝐱)
583-
∂_y = PartialDerivative{2}(𝐱)
582+
∂_x = Derivative(𝐱, (1,0))
583+
∂_y = Derivative(𝐱, (0,1))
584584
Δ = -((∂_x*W)'*(∂_x*W) + (∂_y*W)'*(∂_y*W))
585585
M = W'W
586586
f = expand(P, splat((x,y) -> exp(x*cos(y))))

0 commit comments

Comments
 (0)