Skip to content

Commit 58e2f79

Browse files
authored
Default recurrencecoefficients (#27)
* test adjoint views work * recurrencecoefficients now defaults to using jacobimatrix
1 parent b316b73 commit 58e2f79

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

Project.toml

Lines changed: 2 additions & 2 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.3.3"
4+
version = "0.3.4"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -28,7 +28,7 @@ ArrayLayouts = "0.6.2"
2828
BandedMatrices = "0.16.5"
2929
BlockArrays = "0.14.1, 0.15"
3030
BlockBandedMatrices = "0.10"
31-
ContinuumArrays = "0.6.2"
31+
ContinuumArrays = "0.6.4"
3232
DomainSets = "0.4, 0.5"
3333
FFTW = "1.1"
3434
FastGaussQuadrature = "0.4.3"

src/ClassicalOrthogonalPolynomials.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ The relationship with the Jacobi matrix is:
144144
C[n+1]/A[n+1] == X[n,n+1]
145145
```
146146
"""
147-
recurrencecoefficients(P) = error("Override for $(typeof(P))")
147+
function recurrencecoefficients(Q::AbstractQuasiMatrix{T}) where T
148+
X = jacobimatrix(Q)
149+
c,a,b = subdiagonaldata(X), diagonaldata(X), supdiagonaldata(X)
150+
inv.(c), -(a ./ c), Vcat(zero(T), b) ./ c
151+
end
148152

149153

150154
const WeightedOrthogonalPolynomial{T, A<:AbstractQuasiVector, B<:OrthogonalPolynomial} = WeightedBasis{T, A, B}

src/lanczos.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ axes(Q::LanczosPolynomial) = (axes(Q.w,1),OneToInf())
183183
_p0(Q::LanczosPolynomial) = inv(Q.data.γ[1])*_p0(Q.P)
184184

185185
jacobimatrix(Q::LanczosPolynomial) = SymTridiagonal(LanczosJacobiBand(Q.data, :d), LanczosJacobiBand(Q.data, :du))
186-
recurrencecoefficients(Q::LanczosPolynomial) = normalized_recurrencecoefficients(Q)
187186

188187
Base.summary(io::IO, Q::LanczosPolynomial{T}) where T = print(io, "LanczosPolynomial{$T} with weight with singularities $(singularities(Q.w))")
189188
Base.show(io::IO, Q::LanczosPolynomial{T}) where T = summary(io, Q)

src/normalized.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,6 @@ axes(Q::Normalized) = axes(Q.P)
5555

5656
_p0(Q::Normalized) = Q.scaling[1]
5757

58-
# p_{n+1} = (A_n * x + B_n) * p_n - C_n * p_{n-1}
59-
# q_{n+1}/h[n+1] = (A_n * x + B_n) * q_n/h[n] - C_n * p_{n-1}/h[n-1]
60-
# 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}
61-
62-
function normalized_recurrencecoefficients(Q::AbstractQuasiMatrix{T}) where T
63-
X = jacobimatrix(Q)
64-
a,b = diagonaldata(X), supdiagonaldata(X)
65-
inv.(b), -(a ./ b), Vcat(zero(T), b) ./ b
66-
end
67-
68-
recurrencecoefficients(Q::Normalized{T}) where T = normalized_recurrencecoefficients(Q)
6958

7059
# x * p[n] = c[n-1] * p[n-1] + a[n] * p[n] + b[n] * p[n+1]
7160
# x * q[n]/h[n] = c[n-1] * q[n-1]/h[n-1] + a[n] * q[n]/h[n] + b[n] * q[n+1]/h[n+1]

test/test_chebyshev.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ import ContinuumArrays: MappedWeightedBasisLayout, Map
349349
@test chebyshevu.(0:5, BigFloat(1)/10) == ChebyshevU{BigFloat}()[BigFloat(1)/10, 1:6]
350350
@test chebyshevu.(0:5, 2) == Base.unsafe_getindex(ChebyshevU(), 2, 1:6)
351351
end
352+
353+
@testset "Adjoint views" begin
354+
T = ChebyshevT(); U = ChebyshevU()
355+
D = Derivative(axes(T,1))
356+
V = view(T,:,[1,3,4])
357+
@test (U\(D*V))[1:5,:] == (U \ (V'D')')[1:5,:] == (U\(D*T))[1:5,[1,3,4]]
358+
end
352359
end
353360

354361
struct QuadraticMap{T} <: Map{T} end

0 commit comments

Comments
 (0)