Skip to content

Commit 01eecab

Browse files
authored
ContinuumArray 0.19 (#227)
* ContinuumArray 0.19 * fix diff_layout * Update ultraspherical.jl * JacobiWeight template * Update Project.toml * Update normalized.jl * add tests
1 parent 2c05699 commit 01eecab

File tree

8 files changed

+64
-32
lines changed

8 files changed

+64
-32
lines changed

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClassicalOrthogonalPolynomials"
22
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.14.4"
4+
version = "0.15"
55

66

77
[deps]
@@ -38,23 +38,23 @@ ArrayLayouts = "1.3.1"
3838
BandedMatrices = "1"
3939
BlockArrays = "1"
4040
BlockBandedMatrices = "0.13"
41-
ContinuumArrays = "0.18.3"
41+
ContinuumArrays = "0.19"
4242
DomainSets = "0.6, 0.7"
4343
DynamicPolynomials = "0.6"
4444
FFTW = "1.1"
4545
FastGaussQuadrature = "1"
4646
FastTransforms = "0.16.6, 0.17"
4747
FillArrays = "1"
4848
HypergeometricFunctions = "0.3.4"
49-
InfiniteArrays = " 0.14, 0.15"
50-
InfiniteLinearAlgebra = "0.8, 0.9"
49+
InfiniteArrays = " 0.15"
50+
InfiniteLinearAlgebra = "0.9"
5151
IntervalSets = "0.7"
5252
LazyArrays = "2.2"
53-
LazyBandedMatrices = "0.10, 0.11"
53+
LazyBandedMatrices = "0.11"
5454
MutableArithmetics = "1"
55-
QuasiArrays = "0.11"
55+
QuasiArrays = "0.12"
5656
RecurrenceRelationshipArrays = "0.1.2"
57-
RecurrenceRelationships = "0.1.1, 0.2"
57+
RecurrenceRelationships = "0.2"
5858
SpecialFunctions = "1.0, 2"
5959
julia = "1.10"
6060

src/ClassicalOrthogonalPolynomials.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import QuasiArrays: cardinality, checkindex, QuasiAdjoint, QuasiTranspose, Inclu
3434

3535
import InfiniteArrays: OneToInf, InfAxes, Infinity, AbstractInfUnitRange, InfiniteCardinal, InfRanges
3636
import InfiniteLinearAlgebra: chop!, chop, pad, choplength, compatible_resize!, partialcholesky!
37-
import ContinuumArrays: Basis, Weight, basis_axes, @simplify, Identity, AbstractAffineQuasiVector, ProjectionFactorization,
37+
import ContinuumArrays: Basis, Weight, basis_axes, @simplify, AbstractAffineQuasiVector, ProjectionFactorization,
3838
grid, plotgrid, plotgrid_layout, plotvalues_layout, grid_layout, transform_ldiv, TransformFactorization, QInfAxes, broadcastbasis, ExpansionLayout, basismap,
3939
AffineQuasiVector, AffineMap, AbstractWeightLayout, AbstractWeightedBasisLayout, WeightedBasisLayout, WeightedBasisLayouts, demap, AbstractBasisLayout, BasisLayout,
4040
checkpoints, weight, unweighted, MappedBasisLayouts, sum_layout, invmap, plan_ldiv, layout_broadcasted, MappedBasisLayout, SubBasisLayout, broadcastbasis_layout,
@@ -90,6 +90,8 @@ represents an OP multiplied by its orthogonality weight.
9090
"""
9191
struct WeightedOPLayout{Lay<:AbstractOPLayout} <: AbstractWeightedBasisLayout end
9292

93+
grid_layout(::WeightedOPLayout, P, n) = grid(unweighted(P), n)
94+
9395
isorthogonalityweighted(::WeightedOPLayout, _) = true
9496
function isorthogonalityweighted(::AbstractWeightedBasisLayout, wS)
9597
w,S = arguments(wS)
@@ -246,7 +248,7 @@ grammatrix_layout(::WeightedOPLayout{MappedOPLayout}, P) = grammatrix_layout(Map
246248

247249
OrthogonalPolynomial(w::Weight) =error("Override for $(typeof(w))")
248250

249-
@simplify *(B::Identity, C::OrthogonalPolynomial) = ApplyQuasiMatrix(*, C, jacobimatrix(C))
251+
@simplify *(B::QuasiDiagonal{<:Any,<:Inclusion}, C::OrthogonalPolynomial) = ApplyQuasiMatrix(*, C, jacobimatrix(C))
250252

251253
function layout_broadcasted(::Tuple{PolynomialLayout,AbstractOPLayout}, ::typeof(*), x::Inclusion, C)
252254
x == axes(C,1) || throw(DimensionMismatch())

src/classical/jacobi.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ julia> axes(J)
3838
(Inclusion(-1.0 .. 1.0 (Chebyshev)),)
3939
```
4040
"""
41-
struct JacobiWeight{T} <: AbstractJacobiWeight{T}
42-
a::T
43-
b::T
44-
JacobiWeight{T}(a, b) where T = new{T}(convert(T,a), convert(T,b))
41+
struct JacobiWeight{T,V} <: AbstractJacobiWeight{T}
42+
a::V
43+
b::V
44+
JacobiWeight{T,V}(a, b) where {T,V} = new{T,V}(convert(V,a), convert(V,b))
4545
end
4646

47-
JacobiWeight(a::V, b::T) where {T,V} = JacobiWeight{promote_type(T,V)}(a,b)
47+
JacobiWeight{T}(a::V, b::V) where {T,V} = JacobiWeight{T,V}(a, b)
48+
JacobiWeight{T}(a, b) where T = JacobiWeight{T}(promote(a,b)...)
49+
JacobiWeight(a::V, b::T) where {T,V} = JacobiWeight{float(promote_type(T,V))}(a, b)
50+
4851

4952
"""
5053
jacobiweight(a,b, d::AbstractInterval)
@@ -71,9 +74,9 @@ AbstractQuasiVector{T}(w::JacobiWeight) where T = JacobiWeight{T}(w.a, w.b)
7174

7275
==(A::JacobiWeight, B::JacobiWeight) = A.b == B.b && A.a == B.a
7376

74-
function getindex(w::JacobiWeight, x::Number)
77+
function getindex(w::JacobiWeight{T}, x::Number) where T
7578
x axes(w,1) || throw(BoundsError())
76-
(1-x)^w.a * (1+x)^w.b
79+
convert(T, (1-x)^w.a * (1+x)^w.b)
7780
end
7881

7982
show(io::IO, P::JacobiWeight) = summary(io, P)
@@ -479,6 +482,8 @@ end
479482
broadcastbasis(::typeof(+), w_A::Weighted{<:Any,<:Jacobi}, w_B::Weighted{<:Any,<:Jacobi}) = broadcastbasis(+, convert(WeightedBasis,w_A), convert(WeightedBasis,w_B))
480483
broadcastbasis(::typeof(+), w_A::Weighted{<:Any,<:Jacobi}, w_B::WeightedJacobi) = broadcastbasis(+, convert(WeightedBasis,w_A), w_B)
481484
broadcastbasis(::typeof(+), w_A::WeightedJacobi, w_B::Weighted{<:Any,<:Jacobi}) = broadcastbasis(+, w_A, convert(WeightedBasis,w_B))
485+
broadcastbasis(::typeof(+), A::Jacobi, B::Weighted{<:Any,<:Jacobi{<:Any,<:Integer}}) = A
486+
broadcastbasis(::typeof(+), A::Weighted{<:Any,<:Jacobi{<:Any,<:Integer}}, B::Jacobi) = B
482487

483488
function \(w_A::WeightedJacobi, w_B::WeightedJacobi)
484489
wA,A = w_A.args

src/classical/ultraspherical.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ end
139139

140140
# higher order
141141

142-
function diff(::ChebyshevT{T}, m::Integer; dims=1) where T
142+
function diff(S::ChebyshevT{T}, m::Integer; dims=1) where T
143+
iszero(m) && return S
144+
isone(m) && return diff(S)
143145
μ = pochhammer(one(T),m-1)*convert(T,2)^(m-1)
144146
D = _BandedMatrix((μ * (0:∞))', ℵ₀, -m, m)
145147
ApplyQuasiMatrix(*, Ultraspherical{T}(m), D)

src/lanczos.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,4 @@ broadcastbasis(::typeof(+), P::Union{Normalized,LanczosPolynomial}, Q::Union{Nor
233233
broadcastbasis(::typeof(+), P::Union{Normalized,LanczosPolynomial}, Q) = broadcastbasis(+, P.P, Q)
234234
broadcastbasis(::typeof(+), P, Q::Union{Normalized,LanczosPolynomial}) = broadcastbasis(+, P, Q.P)
235235

236-
diff_layout(::LanczosLayout, P::AbstractQuasiMatrix, dims...) = diff_layout(ApplyLayout{typeof(*)}(), P, dims...)
236+
diff_layout(::LanczosLayout, P::AbstractQuasiMatrix, order...; dims...) = diff_layout(ApplyLayout{typeof(*)}(), P, order...; dims...)

src/normalized.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ _sum(p::SubQuasiArray{T,1,<:Weighted,<:Tuple{Inclusion,Int}}, ::Colon) where T =
299299
demap(W::Weighted) = Weighted(demap(W.P))
300300
basismap(W::Weighted) = basismap(W.P)
301301
const MappedOPLayouts = Union{MappedOPLayout,WeightedOPLayout{MappedOPLayout}}
302-
diff_layout(::MappedOPLayouts, A, dims...) = diff_layout(MappedBasisLayout(), A, dims...)
302+
diff_layout(::MappedOPLayouts, A, order::Int; dims...) = diff_layout(MappedBasisLayout(), A, order; dims...)
303+
diff_layout(::MappedOPLayouts, A, order...; dims...) = diff_layout(MappedBasisLayout(), A, order...; dims...)
303304

304-
diff_layout(::AbstractNormalizedOPLayout, A, dims...) = diff_layout(ApplyLayout{typeof(*)}(), A, dims...)
305+
diff_layout(::AbstractNormalizedOPLayout, A, order...; dims...) = diff_layout(ApplyLayout{typeof(*)}(), A, order...; dims...)

test/test_jacobi.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,19 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, basis, MulQuasiMa
537537
@testset "conversion not implemented" begin
538538
@test_throws ArgumentError Jacobi(0,0) \ Jacobi(1.1,2.1)
539539
end
540+
541+
@testset "broadcastbasis" begin
542+
a = Jacobi(1,1) * [1; zeros(∞)]
543+
b = Weighted(Jacobi(1,1)) * [1; zeros(∞)]
544+
c = Weighted(Jacobi(2,3)) * [1; zeros(∞)]
545+
546+
@test basis(a+b) == basis(b+a) == basis(a+c) == basis(c+a) == Jacobi(1,1)
547+
@test a[0.1]+b[0.1] (a+b)[0.1] (b+a)[0.1]
548+
end
549+
550+
@testset "Weighted expand" begin
551+
W = Weighted(Jacobi(1,1))
552+
@test expand(W, x -> (1-x^2)*exp(x))[0.1] (1-0.1^2)*exp(0.1)
553+
@test grid(W, 5) == grid(W.P, 5)
554+
end
540555
end

test/test_lanczos.jl

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,23 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedColumns, or
303303
@test jacobimatrix(Q)[1,1] 1/3
304304
@test Q[0.5,1:3] [1, 1.369306393762913, 0.6469364618834543]
305305
end
306-
end
307-
308-
@testset "#197" begin
309-
@test _emptymaximum(1:5) == 5
310-
@test _emptymaximum(1:0) == 0
311-
x = Inclusion(ChebyshevInterval())
312-
f = exp.(x)
313-
QQ = LanczosPolynomial(f)
314-
R = LanczosConversion(QQ.data)
315-
v = cache(Zeros(∞))
316-
@test (R \ v)[1:500] == zeros(500)
317-
@test (R * v)[1:500] == zeros(500)
306+
307+
@testset "#197" begin
308+
@test _emptymaximum(1:5) == 5
309+
@test _emptymaximum(1:0) == 0
310+
x = Inclusion(ChebyshevInterval())
311+
f = exp.(x)
312+
QQ = LanczosPolynomial(f)
313+
R = LanczosConversion(QQ.data)
314+
v = cache(Zeros(∞))
315+
@test (R \ v)[1:500] == zeros(500)
316+
@test (R * v)[1:500] == zeros(500)
317+
end
318+
319+
@testset "diff" begin
320+
P = Normalized(Legendre())
321+
x = axes(P,1)
322+
Q = LanczosPolynomial(exp.(x))
323+
@test diff(Q)[0.1,3] -0.1637907411174539
324+
end
318325
end

0 commit comments

Comments
 (0)