Skip to content

Commit d37ac29

Browse files
authored
Improvements to Normalized (#8)
* Update normalized.jl * custom normalized * Actually super simple... duh... * Simplify recurrencecoefficients * Switch to Infinities.jl * Update Project.toml * Move to new Bi/Tri/SymTridiagonal * fix some tests * tests pass * Update Project.toml * Update Project.toml * Update Project.toml * Update Project.toml * Update Project.toml * Realised Hermite and Stieltjes tests weren't being run... need to come back later and fix bugs * tests pass
1 parent 3450e6f commit d37ac29

19 files changed

+130
-114
lines changed

Project.toml

Lines changed: 13 additions & 11 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.1.2"
4+
version = "0.2.0"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -18,35 +18,37 @@ InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
1818
InfiniteLinearAlgebra = "cde9dba0-b1de-11e9-2c62-0bab9446c55c"
1919
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
2020
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
21+
LazyBandedMatrices = "d7e5e226-e90b-4449-9968-0f923699bf6f"
2122
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2223
QuasiArrays = "c4ea9172-b204-11e9-377d-29865faadc5c"
24+
SemiseparableMatrices = "f8ebbe35-cbfb-4060-bf7f-b10e4670cf57"
2325
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2426

2527
[compat]
26-
ArrayLayouts = "0.5.3"
27-
BandedMatrices = "0.16.4"
28+
ArrayLayouts = "0.6.2"
29+
BandedMatrices = "0.16.5"
2830
BlockArrays = "0.14.1"
2931
BlockBandedMatrices = "0.10"
30-
ContinuumArrays = "0.5"
32+
ContinuumArrays = "0.6"
3133
DomainSets = "0.4, 0.5"
3234
FFTW = "1.1"
3335
FastGaussQuadrature = "0.4.3"
3436
FastTransforms = "0.11, 0.12"
3537
FillArrays = "0.11"
36-
InfiniteArrays = "0.9"
37-
InfiniteLinearAlgebra = "0.4.6"
38-
IntervalSets = "0.3.1, 0.4, 0.5"
39-
LazyArrays = "0.20.5"
40-
QuasiArrays = "0.4.5"
38+
InfiniteArrays = "0.10"
39+
InfiniteLinearAlgebra = "0.5.2"
40+
IntervalSets = "0.5"
41+
LazyArrays = "0.20.6"
42+
LazyBandedMatrices = "0.5"
43+
QuasiArrays = "0.4.6"
4144
SpecialFunctions = "0.10, 1"
4245
julia = "1.5"
4346

4447
[extras]
4548
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
4649
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
47-
LazyBandedMatrices = "d7e5e226-e90b-4449-9968-0f923699bf6f"
4850
SemiseparableMatrices = "f8ebbe35-cbfb-4060-bf7f-b10e4670cf57"
4951
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5052

5153
[targets]
52-
test = ["Base64", "Test", "ForwardDiff", "SemiseparableMatrices", "LazyBandedMatrices"]
54+
test = ["Base64", "Test", "ForwardDiff", "SemiseparableMatrices"]

src/ClassicalOrthogonalPolynomials.jl

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module ClassicalOrthogonalPolynomials
22
using ContinuumArrays, QuasiArrays, LazyArrays, FillArrays, BandedMatrices, BlockArrays,
33
IntervalSets, DomainSets, ArrayLayouts, SpecialFunctions,
4-
InfiniteLinearAlgebra, InfiniteArrays, LinearAlgebra, FastGaussQuadrature, FastTransforms, FFTW
4+
InfiniteLinearAlgebra, InfiniteArrays, LinearAlgebra, FastGaussQuadrature, FastTransforms, FFTW,
5+
LazyBandedMatrices
56

67
import Base: @_inline_meta, axes, getindex, convert, prod, *, /, \, +, -,
78
IndexStyle, IndexLinear, ==, OneTo, tail, similar, copyto!, copy,
@@ -10,8 +11,11 @@ import Base: @_inline_meta, axes, getindex, convert, prod, *, /, \, +, -,
1011
import Base.Broadcast: materialize, BroadcastStyle, broadcasted
1112
import LazyArrays: MemoryLayout, Applied, ApplyStyle, flatten, _flatten, colsupport, adjointlayout,
1213
sub_materialize, arguments, sub_paddeddata, paddeddata, PaddedLayout, resizedata!, LazyVector, ApplyLayout, call,
13-
_mul_arguments, CachedVector, CachedMatrix, LazyVector, LazyMatrix, axpy!, AbstractLazyLayout, BroadcastLayout, AbstractCachedVector
14-
import ArrayLayouts: MatMulVecAdd, materialize!, _fill_lmul!, sublayout, sub_materialize, lmul!, ldiv!, ldiv, transposelayout, triangulardata
14+
_mul_arguments, CachedVector, CachedMatrix, LazyVector, LazyMatrix, axpy!, AbstractLazyLayout, BroadcastLayout,
15+
AbstractCachedVector, AbstractCachedMatrix
16+
import ArrayLayouts: MatMulVecAdd, materialize!, _fill_lmul!, sublayout, sub_materialize, lmul!, ldiv!, ldiv, transposelayout, triangulardata,
17+
subdiagonaldata, diagonaldata, supdiagonaldata
18+
import LazyBandedMatrices: SymTridiagonal, Bidiagonal, Tridiagonal
1519
import LinearAlgebra: pinv, factorize, qr, adjoint, transpose
1620
import BandedMatrices: AbstractBandedLayout, AbstractBandedMatrix, _BandedMatrix, bandeddata
1721
import FillArrays: AbstractFill, getindex_value
@@ -22,7 +26,7 @@ import QuasiArrays: cardinality, checkindex, QuasiAdjoint, QuasiTranspose, Inclu
2226
LazyQuasiArray, LazyQuasiVector, LazyQuasiMatrix, LazyLayout, LazyQuasiArrayStyle,
2327
_getindex, layout_getindex, _factorize
2428

25-
import InfiniteArrays: OneToInf, InfAxes, Infinity, AbstractInfUnitRange
29+
import InfiniteArrays: OneToInf, InfAxes, Infinity, AbstractInfUnitRange, InfiniteCardinal, InfRanges
2630
import ContinuumArrays: Basis, Weight, basis, @simplify, Identity, AbstractAffineQuasiVector, ProjectionFactorization,
2731
inbounds_getindex, grid, transform, transform_ldiv, TransformFactorization, QInfAxes, broadcastbasis, Expansion,
2832
AffineQuasiVector, AffineMap, WeightLayout, WeightedBasisLayout, WeightedBasisLayouts, demap, AbstractBasisLayout, BasisLayout,
@@ -53,7 +57,7 @@ include("interlace.jl")
5357
cardinality(::FullSpace{<:AbstractFloat}) = ℵ₁
5458
cardinality(::EuclideanDomain) = ℵ₁
5559

56-
transform_ldiv(A, f, ::Tuple{<:Any,Infinity}) = adaptivetransform_ldiv(A, f)
60+
transform_ldiv(A, f, ::Tuple{<:Any,InfiniteCardinal{0}}) = adaptivetransform_ldiv(A, f)
5761

5862
function chop!(c::AbstractVector, tol::Real)
5963
@assert tol >= 0
@@ -213,6 +217,17 @@ function broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), x::Inclusion, C::Sub
213217
P[kr, :] * view(X,:,jr)
214218
end
215219

220+
function broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), x::Inclusion, C::SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:AbstractAffineQuasiVector,<:Slice}})
221+
T = promote_type(eltype(x), eltype(C))
222+
x == axes(C,1) || throw(DimensionMismatch())
223+
P = parent(C)
224+
kr,_ = parentindices(C)
225+
y = axes(P,1)
226+
Y = P \ (y .* P)
227+
X = kr.A \ (Y - kr.b * Eye{T}(∞))
228+
P[kr, :] * X
229+
end
230+
216231
function jacobimatrix(C::SubQuasiArray{T,2,<:Any,<:Tuple{AbstractAffineQuasiVector,Slice}}) where T
217232
P = parent(C)
218233
kr,jr = parentindices(C)
@@ -250,6 +265,11 @@ function \(A::SubQuasiArray{<:Any,2,<:OrthogonalPolynomial}, B::SubQuasiArray{<:
250265
(parent(A) \ parent(B))[jA, jB]
251266
end
252267

268+
function \(A::SubQuasiArray{<:Any,2,<:OrthogonalPolynomial,<:Tuple{Any,Slice}}, B::SubQuasiArray{<:Any,2,<:OrthogonalPolynomial,<:Tuple{Any,Slice}})
269+
axes(A,1) == axes(B,1) || throw(DimensionMismatch())
270+
parent(A) \ parent(B)
271+
end
272+
253273
function \(wA::WeightedOrthogonalPolynomial, wB::WeightedOrthogonalPolynomial)
254274
w_A,A = arguments(wA)
255275
w_B,B = arguments(wB)

src/chebyshev.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,11 @@ factorize(L::SubQuasiArray{T,2,<:ChebyshevU,<:Tuple{<:Inclusion,<:OneTo}}) where
106106
# Jacobi Matrix
107107
########
108108

109-
jacobimatrix(C::ChebyshevT{T}) where T =
110-
_BandedMatrix(Vcat(Fill(one(T)/2,1,∞),
111-
Zeros{T}(1,∞),
112-
Hcat(one(T), Fill(one(T)/2,1,∞))), ∞, 1, 1)
109+
jacobimatrix(C::ChebyshevT{T}) where T =
110+
Tridiagonal(Vcat(one(T), Fill(one(T)/2,∞)), Zeros{T}(∞), Fill(one(T)/2,∞))
113111

114112
jacobimatrix(C::ChebyshevU{T}) where T =
115-
_BandedMatrix(Vcat(Fill(one(T)/2,1,∞),
116-
Zeros{T}(1,∞),
117-
Fill(one(T)/2,1,∞)), ∞, 1, 1)
113+
SymTridiagonal(Zeros{T}(∞), Fill(one(T)/2,∞))
118114

119115

120116

@@ -151,7 +147,7 @@ end
151147
# Ultraspherical(1)\(D*Chebyshev())
152148
@simplify function *(D::Derivative{<:Any,<:ChebyshevInterval}, S::ChebyshevT)
153149
T = promote_type(eltype(D),eltype(S))
154-
A = _BandedMatrix((zero(T):∞)', , -1,1)
150+
A = _BandedMatrix((zero(T):∞)', ℵ₀, -1,1)
155151
ApplyQuasiMatrix(*, ChebyshevU{T}(), A)
156152
end
157153

@@ -163,14 +159,14 @@ function \(U::ChebyshevU, C::ChebyshevT)
163159
T = promote_type(eltype(U), eltype(C))
164160
_BandedMatrix(Vcat(-Ones{T}(1,∞)/2,
165161
Zeros{T}(1,∞),
166-
Hcat(Ones{T}(1,1),Ones{T}(1,∞)/2)), , 0,2)
162+
Hcat(Ones{T}(1,1),Ones{T}(1,∞)/2)), ℵ₀, 0,2)
167163
end
168164

169165
function \(w_A::WeightedChebyshevT, w_B::WeightedChebyshevU)
170166
wA,A = w_A.args
171167
wB,B = w_B.args
172168
T = promote_type(eltype(w_A), eltype(w_B))
173-
_BandedMatrix(Vcat(Fill(one(T)/2, 1, ∞), Zeros{T}(1, ∞), Fill(-one(T)/2, 1, ∞)), , 2, 0)
169+
_BandedMatrix(Vcat(Fill(one(T)/2, 1, ∞), Zeros{T}(1, ∞), Fill(-one(T)/2, 1, ∞)), ℵ₀, 2, 0)
174170
end
175171

176172
\(T::ChebyshevT, U::ChebyshevU) = inv(U \ T)

src/fourier.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ end
6464
function broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), c::BroadcastQuasiVector{<:Any,typeof(cos),<:Tuple{<:Inclusion{<:Any,<:FullSpace}}}, F::Fourier)
6565
axes(c,1) == axes(F,1) || throw(DimensionMismatch())
6666
T = promote_type(eltype(c), eltype(F))
67-
F*mortar(Tridiagonal(Vcat([reshape([0; one(T)],2,1)], Fill(Matrix(one(T)/2*I,2,2),∞)),
67+
# Use LinearAlgebra.Tridiagonal for now since broadcasting support not complete for LazyBandedMatrices.Tridiagonal
68+
F*mortar(LinearAlgebra.Tridiagonal(Vcat([reshape([0; one(T)],2,1)], Fill(Matrix(one(T)/2*I,2,2),∞)),
6869
Vcat([zeros(T,1,1)], Fill(Matrix(zero(T)I,2,2),∞)),
6970
Vcat([[0 one(T)/2]], Fill(Matrix(one(T)/2*I,2,2),∞))))
7071
end
@@ -73,7 +74,8 @@ end
7374
function broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), s::BroadcastQuasiVector{<:Any,typeof(sin),<:Tuple{<:Inclusion{<:Any,<:FullSpace}}}, F::Fourier)
7475
axes(s,1) == axes(F,1) || throw(DimensionMismatch())
7576
T = promote_type(eltype(s), eltype(F))
76-
F*mortar(Tridiagonal(Vcat([reshape([one(T); 0],2,1)], Fill([0 one(T)/2; -one(T)/2 0],∞)),
77+
# Use LinearAlgebra.Tridiagonal for now since broadcasting support not complete for LazyBandedMatrices.Tridiagonal
78+
F*mortar(LinearAlgebra.Tridiagonal(Vcat([reshape([one(T); 0],2,1)], Fill([0 one(T)/2; -one(T)/2 0],∞)),
7779
Vcat([zeros(T,1,1)], Fill(Matrix(zero(T)*I,2,2),∞)),
7880
Vcat([[one(T)/2 0]], Fill([0 -one(T)/2; one(T)/2 0],∞))))
7981
end

src/hermite.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ axes(::Hermite{T}) where T = (Inclusion(ℝ), oneto(∞))
1717
# H_{n+1} = 2x H_n - 2n H_{n-1}
1818
# 1/2 * H_{n+1} + n H_{n-1} = x H_n
1919
# x*[H_0 H_1 H_2 …] = [H_0 H_1 H_2 …] * [0 1; 1/2 0 2; 1/2 0 3; …]
20-
function jacobimatrix(H::Hermite{T}) where T
21-
# X = BandedMatrix(1 => 1:∞, -1 => Fill(one(T)/2,∞))
22-
_BandedMatrix(Vcat((0:∞)', Zeros(1,∞), Fill(one(T)/2,1,∞)), ∞, 1, 1)
23-
end
20+
jacobimatrix(H::Hermite{T}) where T = Tridiagonal(Fill(one(T)/2,∞), Zeros{T}(∞), one(T):∞)
21+
recurrencecoefficients(H::Hermite{T}) where T = Fill{T}(2,∞), Zeros{T}(∞), zero(T):2:
2422

2523
@simplify function *(Ac::QuasiAdjoint{<:Any,<:Hermite}, B::WeightedBasis{<:Any,<:HermiteWeight,<:Hermite})
2624
T = promote_type(eltype(Ac), eltype(B))
@@ -33,6 +31,6 @@ end
3331

3432
@simplify function *(D::Derivative, H::Hermite)
3533
T = promote_type(eltype(D),eltype(H))
36-
D = _BandedMatrix((zero(T):2:∞)', , -1,1)
34+
D = _BandedMatrix((zero(T):2:∞)', ℵ₀, -1,1)
3735
H*D
3836
end

src/jacobi.jl

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ end
213213
# Jacobi Matrix
214214
########
215215

216-
jacobimatrix(::Legendre{T}) where T = _BandedMatrix(Vcat(((zero(T):∞)./(1:2:∞))', Zeros{T}(1,∞), ((one(T):∞)./(1:2:∞))'), ∞, 1,1)
216+
jacobimatrix(::Legendre{T}) where T = Tridiagonal((one(T):∞)./(1:2:∞), Zeros{T}(∞), (one(T):∞)./(3:2:∞))
217217

218218
# These return vectors A[k], B[k], C[k] are from DLMF. Cause of MikaelSlevinsky we need an extra entry in C ... for now.
219219
function recurrencecoefficients(::Legendre{T}) where T
@@ -226,9 +226,9 @@ function jacobimatrix(J::Jacobi)
226226
n = 0:
227227
B = Vcat(2 / (a+b+2), 2 .* (n .+ 2) .* (n .+ (a+b+2)) ./ ((2n .+ (a+b+3)) .* (2n .+ (a+b+4))))
228228
A = Vcat((b-a) / (a+b+2), (b^2-a^2) ./ ((2n .+ (a+b+2)) .* (2n .+ (a+b+4))))
229-
C = 2 .* (n .+ a) .* (n .+ b) ./ ((2n .+ (a+b)) .* (2n .+ (a+b+1)))
229+
C = 2 .* (n .+ (a + 1)) .* (n .+ (b + 1)) ./ ((2n .+ (a+b+2)) .* (2n .+ (a+b+3)))
230230

231-
_BandedMatrix(Vcat(C',A',B'), ∞, 1,1)
231+
Tridiagonal(B,A,C)
232232
end
233233

234234
function recurrencecoefficients(P::Jacobi)
@@ -260,17 +260,13 @@ function \(A::Jacobi, B::Jacobi)
260260
if A.a a && A.b b
261261
Eye{T}(∞)
262262
elseif isone(-a-b) && A.a == a && A.b == b+1
263-
_BandedMatrix(Vcat((((0:∞) .+ a)./((1:2:∞) .+ (a+b)))',
264-
Vcat(1,((2:∞) .+ (a+b))./((3:2:∞) .+ (a+b)))'), ∞, 0,1)
263+
Bidiagonal(Vcat(1, ((2:∞) .+ (a+b)) ./ ((3:2:∞) .+ (a+b))), ((1:∞) .+ a) ./ ((3:2:∞) .+ (a+b)), :U)
265264
elseif isone(-a-b) && A.a == a+1 && A.b == b
266-
_BandedMatrix(Vcat((-((0:∞) .+ b)./((1:2:∞) .+ (a+b)))',
267-
Vcat(1,((2:∞) .+ (a+b))./((3:2:∞) .+ (a+b)))'), ∞, 0,1)
265+
Bidiagonal(Vcat(1, ((2:∞) .+ (a+b)) ./ ((3:2:∞) .+ (a+b))), -((1:∞) .+ b) ./ ((3:2:∞) .+ (a+b)), :U)
268266
elseif A.a == a && A.b == b+1
269-
_BandedMatrix(Vcat((((0:∞) .+ a)./((1:2:∞) .+ (a+b)))',
270-
(((1:∞) .+ (a+b))./((1:2:∞) .+ (a+b)))'), ∞, 0,1)
267+
Bidiagonal(((1:∞) .+ (a+b))./((1:2:∞) .+ (a+b)), ((1:∞) .+ a)./((3:2:∞) .+ (a+b)), :U)
271268
elseif A.a == a+1 && A.b == b
272-
_BandedMatrix(Vcat((-((0:∞) .+ b)./((1:2:∞) .+ (a+b)))',
273-
(((1:∞) .+ (a+b))./((1:2:∞) .+ (a+b)))'), ∞, 0,1)
269+
Bidiagonal(((1:∞) .+ (a+b))./((1:2:∞) .+ (a+b)), -((1:∞) .+ b)./((3:2:∞) .+ (a+b)), :U)
274270
elseif A.a a+1
275271
J = Jacobi(a+1,b)
276272
(A \ J) * (J \ B)
@@ -310,9 +306,9 @@ function \(w_A::WeightedJacobi, w_B::WeightedJacobi)
310306
if wA == wB
311307
A \ B
312308
elseif B.a == A.a && B.b == A.b+1 && wB.b == wA.b+1 && wB.a == wA.a
313-
_BandedMatrix(Vcat((((2:2:∞) .+ 2A.b)./((2:2:∞) .+ (A.a+A.b)))', ((2:2:∞)./((2:2:∞) .+ (A.a+A.b)))'), ∞, 1,0)
309+
Bidiagonal(((2:2:∞) .+ 2A.b)./((2:2:∞) .+ (A.a+A.b)), (2:2:∞)./((2:2:∞) .+ (A.a+A.b)), :L)
314310
elseif B.a == A.a+1 && B.b == A.b && wB.b == wA.b && wB.a == wA.a+1
315-
_BandedMatrix(Vcat((((2:2:∞) .+ 2A.a)./((2:2:∞) .+ (A.a+A.b)))', -((2:2:∞)./((2:2:∞) .+ (A.a+A.b)))'), ∞, 1,0)
311+
Bidiagonal(((2:2:∞) .+ 2A.a)./((2:2:∞) .+ (A.a+A.b)), -(2:2:∞)./((2:2:∞) .+ (A.a+A.b)), :L)
316312
elseif wB.a wA.a+1
317313
J = JacobiWeight(wB.a-1,wB.b) .* Jacobi(B.a-1,B.b)
318314
(w_A\J) * (J\w_B)
@@ -332,7 +328,7 @@ end
332328

333329
# Jacobi(a+1,b+1)\(D*Jacobi(a,b))
334330
@simplify function *(D::Derivative{<:Any,<:AbstractInterval}, S::Jacobi)
335-
A = _BandedMatrix((((1:∞) .+ (S.a + S.b))/2)', , -1,1)
331+
A = _BandedMatrix((((1:∞) .+ (S.a + S.b))/2)', ℵ₀, -1,1)
336332
ApplyQuasiMatrix(*, Jacobi(S.a+1,S.b+1), A)
337333
end
338334

@@ -343,13 +339,13 @@ end
343339
if w.a == 0 && w.b == 0
344340
D*S
345341
elseif iszero(w.a) && w.b == b #L_6
346-
A = _BandedMatrix((b:)', ∞, 0,0)
342+
A = Diagonal(b:∞)
347343
ApplyQuasiMatrix(*, JacobiWeight(w.a,b-1) .* Jacobi(a+1,b-1), A)
348344
elseif iszero(w.b) && w.a == a #L_6^t
349-
A = _BandedMatrix(-(a:∞)', ∞, 0,0)
345+
A = Diagonal(-(a:∞))
350346
ApplyQuasiMatrix(*, JacobiWeight(a-1,w.b) .* Jacobi(a-1,b+1), A)
351347
elseif w.a == a && w.b == b # L_1^t
352-
A = _BandedMatrix((-2*(1:∞))', , 1,-1)
348+
A = _BandedMatrix((-2*(1:∞))', ℵ₀, 1,-1)
353349
ApplyQuasiMatrix(*, JacobiWeight(a-1,b-1) .* Jacobi(a-1, b-1), A)
354350
elseif iszero(w.a)
355351
W = (JacobiWeight(w.a, b-1) .* Jacobi(a+1, b-1)) \ (D * (JacobiWeight(w.a,b) .* S))
@@ -373,13 +369,13 @@ function \(L::Legendre, WS::WeightedBasis{Bool,JacobiWeight{Bool},Jacobi{Bool}})
373369
w,S = WS.args
374370
if w.b && w.a
375371
@assert S.b && S.a
376-
_BandedMatrix(Vcat(((2:2:∞)./(3:2:∞))', Zeros(1,∞), (-(2:2:∞)./(3:2:∞))'), , 2,0)
372+
_BandedMatrix(Vcat(((2:2:∞)./(3:2:∞))', Zeros(1,∞), (-(2:2:∞)./(3:2:∞))'), ℵ₀, 2,0)
377373
elseif w.b && !w.a
378374
@assert S.b && !S.a
379-
_BandedMatrix(Ones{eltype(L)}(2,∞), ∞, 1,0)
375+
Bidiagonal(Ones{eltype(L)}(∞), Ones{eltype(L)}(∞), :L)
380376
elseif !w.b && w.a
381377
@assert !S.b && S.a
382-
_BandedMatrix(Vcat(Ones{eltype(L)}(1,∞),-Ones{eltype(L)}(1,∞)), ∞, 1,0)
378+
Bidiagonal(Ones{eltype(L)}(∞), -Ones{eltype(L)}(1,∞), :L)
383379
else
384380
error("Not implemented")
385381
end

src/lanczos.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ end
177177

178178
getindex(A::LanczosRecurrence, I::Integer) = _lanczos_getindex(A, I)
179179
getindex(A::LanczosRecurrence, I::AbstractVector) = _lanczos_getindex(A, I)
180-
getindex(K::LanczosRecurrence, k::AbstractInfUnitRange) = view(K, k)
181-
getindex(K::SubArray{<:Any,1,<:LanczosRecurrence}, k::AbstractInfUnitRange) = view(K, k)
180+
getindex(K::LanczosRecurrence, k::InfRanges{<:Integer}) = view(K, k)
181+
getindex(K::SubArray{<:Any,1,<:LanczosRecurrence}, k::InfRanges{<:Integer}) = view(K, k)
182182

183183

184184
struct LanczosPolynomial{T,XX,WW,Weight,Basis} <: OrthogonalPolynomial{T}

src/normalized.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212

1313
NormalizationConstant(P::AbstractQuasiMatrix{T}) where T = NormalizationConstant{T,typeof(P)}(P)
1414

15-
size(K::NormalizationConstant) = (,)
15+
size(K::NormalizationConstant) = (ℵ₀,)
1616

1717
# How we populate the data
1818
# function _normalizationconstant_fill_data!(K::NormalizationConstant, J::Union{BandedMatrix,Symmetric{<:Any,BandedMatrix},Tridiagonal,SymTridiagonal}, inds)
@@ -77,9 +77,9 @@ _p0(Q::Normalized) = Q.scaling[1]
7777
# q_{n+1} = (h[n+1]/h[n] * A_n * x + h[n+1]/h[n] * B_n) * q_n - h[n+1]/h[n-1] * C_n * p_{n-1}
7878

7979
function recurrencecoefficients(Q::Normalized)
80-
A,B,C = recurrencecoefficients(Q.P)
81-
h = Q.scaling
82-
h[2:∞] ./ h .* A, h[2:∞] ./ h .* B, Vcat(zero(eltype(Q)), h[3:∞] ./ h .* C[2:∞])
80+
X = jacobimatrix(Q.P)
81+
c,a,b = subdiagonaldata(X), diagonaldata(X), supdiagonaldata(X)
82+
inv.(sqrt.(b .* c)), -(a ./ sqrt.(b .* c)), Vcat(zero(eltype(Q)), sqrt.(b .* c) ./ sqrt.(b[2:end] .* c[2:end]))
8383
end
8484

8585
# x * p[n] = c[n-1] * p[n-1] + a[n] * p[n] + b[n] * p[n+1]
@@ -88,12 +88,12 @@ end
8888

8989
# q_{n+1}/h[n+1] = (A_n * x + B_n) * q_n/h[n] - C_n * p_{n-1}/h[n-1]
9090
# q_{n+1} = (h[n+1]/h[n] * A_n * x + h[n+1]/h[n] * B_n) * q_n - h[n+1]/h[n-1] * C_n * p_{n-1}
91-
function jacobimatrix(Q::Normalized)
92-
X = jacobimatrix(Q.P)
93-
a,b = X[band(0)], X[band(-1)]
94-
h = Q.scaling
95-
Symmetric(_BandedMatrix(Vcat(a', (b .* h ./ h[2:end])'), ∞, 1, 0), :L)
91+
92+
function symtridagonalize(X)
93+
c,a,b = subdiagonaldata(X), diagonaldata(X), supdiagonaldata(X)
94+
SymTridiagonal(a, sqrt.(b .* c))
9695
end
96+
jacobimatrix(Q::Normalized) = symtridagonalize(jacobimatrix(Q.P))
9797

9898
orthogonalityweight(Q::Normalized) = orthogonalityweight(Q.P)
9999
singularities(Q::Normalized) = singularities(Q.P)
@@ -131,7 +131,7 @@ _mul_arguments(Q::QuasiAdjoint{<:Any,<:Normalized}) = arguments(ApplyLayout{type
131131

132132
# table stable identity if A.P == B.P
133133
@inline _normalized_ldiv(An, C, Bn) = An \ (C * Bn)
134-
@inline _normalized_ldiv(An, C::Eye{T}, Bn) where T = FillArrays.SquareEye{promote_type(eltype(An),T,eltype(Bn))}()
134+
@inline _normalized_ldiv(An, C::Eye{T}, Bn) where T = FillArrays.SquareEye{promote_type(eltype(An),T,eltype(Bn))}(ℵ₀)
135135
@inline copy(L::Ldiv{<:NormalizedBasisLayout,<:NormalizedBasisLayout}) = _normalized_ldiv(Diagonal(L.A.scaling), L.A.P \ L.B.P, Diagonal(L.B.scaling))
136136
@inline copy(L::Ldiv{Lay,<:NormalizedBasisLayout}) where Lay = copy(Ldiv{Lay,ApplyLayout{typeof(*)}}(L.A, L.B))
137137
@inline copy(L::Ldiv{<:NormalizedBasisLayout,Lay}) where Lay = copy(Ldiv{ApplyLayout{typeof(*)},Lay}(L.A, L.B))

src/stieltjes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ end
1414

1515
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval}, wT::WeightedBasis{<:Any,<:ChebyshevTWeight,<:ChebyshevT})
1616
T = promote_type(eltype(H), eltype(wT))
17-
ApplyQuasiArray(*, ChebyshevU{T}(), _BandedMatrix(Fill(-convert(T,π),1,∞), , -1, 1))
17+
ApplyQuasiArray(*, ChebyshevU{T}(), _BandedMatrix(Fill(-convert(T,π),1,∞), ℵ₀, -1, 1))
1818
end
1919

2020
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval}, wU::WeightedBasis{<:Any,<:ChebyshevUWeight,<:ChebyshevU})
2121
T = promote_type(eltype(H), eltype(wU))
22-
ApplyQuasiArray(*, ChebyshevT{T}(), _BandedMatrix(Fill(convert(T,π),1,∞), , 1, -1))
22+
ApplyQuasiArray(*, ChebyshevT{T}(), _BandedMatrix(Fill(convert(T,π),1,∞), ℵ₀, 1, -1))
2323
end
2424

2525
###

0 commit comments

Comments
 (0)