Skip to content

Commit 11cb452

Browse files
add reference to the docs and readme
1 parent 9f7b253 commit 11cb452

File tree

2 files changed

+65
-26
lines changed

2 files changed

+65
-26
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ julia> @time norm(ipaduatransform(paduatransform(v)) - v)/norm(v)
162162

163163
[1] D. Ruiz—Antolín and A. Townsend, [A nonuniform fast Fourier transform based on low rank approximation](https://doi.org/10.1137/17M1134822), *SIAM J. Sci. Comput.*, **40**:A529–A547, 2018.
164164

165-
[2] T. S. Gutleb, S. Olver and R. M. Slevinsky, [Polynomial and rational measure modifications of orthogonal polynomials via infinite-dimensional banded matrix factorizations](https://arxiv.org/abs/2302.08448), arXiv:2302.08448, 2023.
165+
[2] K. Gumerov, S. Rigg, and R. M. Slevinsky, [Fast measure modification of orthogonal polynomials via matrices with displacement structure](https://arxiv.org/abs/2412.17663), arXiv:2412.17663, 2024.
166166

167-
[3] S. Olver, R. M. Slevinsky, and A. Townsend, [Fast algorithms using orthogonal polynomials](https://doi.org/10.1017/S0962492920000045), *Acta Numerica*, **29**:573—699, 2020.
167+
[3] T. S. Gutleb, S. Olver and R. M. Slevinsky, [Polynomial and rational measure modifications of orthogonal polynomials via infinite-dimensional banded matrix factorizations](https://arxiv.org/abs/2302.08448), arXiv:2302.08448, 2023.
168168

169-
[4] R. M. Slevinsky, [Fast and backward stable transforms between spherical harmonic expansions and bivariate Fourier series](https://doi.org/10.1016/j.acha.2017.11.001), *Appl. Comput. Harmon. Anal.*, **47**:585—606, 2019.
169+
[4] S. Olver, R. M. Slevinsky, and A. Townsend, [Fast algorithms using orthogonal polynomials](https://doi.org/10.1017/S0962492920000045), *Acta Numerica*, **29**:573—699, 2020.
170170

171-
[5] R. M. Slevinsky, [Conquering the pre-computation in two-dimensional harmonic polynomial transforms](https://arxiv.org/abs/1711.07866), arXiv:1711.07866, 2017.
171+
[5] R. M. Slevinsky, [Fast and backward stable transforms between spherical harmonic expansions and bivariate Fourier series](https://doi.org/10.1016/j.acha.2017.11.001), *Appl. Comput. Harmon. Anal.*, **47**:585—606, 2019.
172+
173+
[6] R. M. Slevinsky, [Conquering the pre-computation in two-dimensional harmonic polynomial transforms](https://arxiv.org/abs/1711.07866), arXiv:1711.07866, 2017.

src/GramMatrix.jl

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ abstract type AbstractGramMatrix{T} <: LayoutMatrix{T} end
44
@inline isposdef(G::AbstractGramMatrix) = true
55
@inline colsupport(G::AbstractGramMatrix, j) = colrange(G, j)
66

7+
struct GramMatrix{T, WT <: AbstractMatrix{T}, XT <: AbstractMatrix{T}} <: AbstractGramMatrix{T}
8+
W::WT
9+
X::XT
10+
function GramMatrix{T, WT, XT}(W::WT, X::XT) where {T, WT, XT}
11+
if size(W) size(X)
12+
throw(ArgumentError("Cannot construct a GramMatrix with W and X of different sizes."))
13+
end
14+
if !issymmetric(W)
15+
throw(ArgumentError("Cannot construct a GramMatrix with a nonsymmetric W."))
16+
end
17+
if bandwidths(X) (1, 1)
18+
throw(ArgumentError("Cannot construct a GramMatrix with a nontridiagonal X."))
19+
end
20+
new{T, WT, XT}(W, X)
21+
end
22+
end
23+
724
"""
825
GramMatrix(W::AbstractMatrix, X::AbstractMatrix)
926
@@ -25,24 +42,11 @@ G[:, 1] = 𝐞ₙ, \\quad G[:, 2] = W[n-1, :]X[n-1, n] - Xᵀ W[:, n].
2542
Fast (``O(n^2)``) Cholesky factorization of the Gram matrix returns the
2643
connection coefficients between ``𝐏(x)`` and the polynomials ``𝐐(x)``
2744
orthogonal in the modified inner product, ``𝐏(x) = 𝐐(x) R``.
28-
"""
29-
struct GramMatrix{T, WT <: AbstractMatrix{T}, XT <: AbstractMatrix{T}} <: AbstractGramMatrix{T}
30-
W::WT
31-
X::XT
32-
function GramMatrix{T, WT, XT}(W::WT, X::XT) where {T, WT, XT}
33-
if size(W) size(X)
34-
throw(ArgumentError("Cannot construct a GramMatrix with W and X of different sizes."))
35-
end
36-
if !issymmetric(W)
37-
throw(ArgumentError("Cannot construct a GramMatrix with a nonsymmetric W."))
38-
end
39-
if bandwidths(X) (1, 1)
40-
throw(ArgumentError("Cannot construct a GramMatrix with a nontridiagonal X."))
41-
end
42-
new{T, WT, XT}(W, X)
43-
end
44-
end
4545
46+
See also [`ChebyshevGramMatrix`](@ref) for a special case.
47+
48+
> K. Gumerov, S. Rigg, and R. M. Slevinsky, [Fast measure modification of orthogonal polynomials via matrices with displacement structure](https://arxiv.org/abs/2412.17663), arXiv:2412.17663, 2024.
49+
"""
4650
GramMatrix(W::WT, X::XT) where {T, WT <: AbstractMatrix{T}, XT <: AbstractMatrix{T}} = GramMatrix{T, WT, XT}(W, X)
4751

4852
@inline size(G::GramMatrix) = size(G.W)
@@ -108,6 +112,39 @@ function GramMatrix(μ::PaddedVector{T}, X::XT, p0::T) where {T, XT <: AbstractM
108112
return GramMatrix(Symmetric(W[1:n, 1:n], :L), eval(XT.name.name)(view(X, 1:n, 1:n)))
109113
end
110114

115+
"""
116+
GramMatrix(cnm1::AbstractVector, cn::AbstractVector, X::AbstractMatrix)
117+
118+
Construct a GramMatrix from its last two columns and the multiplication operator.
119+
The recurrence is built from ``XᵀW = WX`` and is used in case the moment method is unstable (such as with Laguerre).
120+
"""
121+
function GramMatrix(cnm1::AbstractVector{T}, cn::AbstractVector{T}, X::XT) where {T, XT <: AbstractMatrix{T}}
122+
N = length(cn)
123+
@assert N == length(cnm1) == size(X, 1) == size(X, 2)
124+
@assert bandwidths(X) == (1, 1)
125+
W = Matrix{T}(undef, N, N)
126+
if N > 0
127+
@inbounds for m in 1:N
128+
W[N, m] = W[m, N] = cn[m]
129+
end
130+
end
131+
if N > 1
132+
@inbounds for m in 1:N
133+
W[N-1, m] = W[m, N-1] = cnm1[m]
134+
end
135+
end
136+
@inbounds @simd for n in N:-1:3
137+
W[1, n-2] = ((X[1, 1]-X[n-1, n-1])*W[1, n-1] + X[2, 1]*W[2, n-1] - X[n, n-1]*W[1, n])/X[n-2, n-1]
138+
for m in 2:n-2
139+
W[m, n-2] = (X[m-1, m]*W[m-1, n-1] + (X[m, m]-X[n-1, n-1])*W[m, n-1] + X[m+1, m]*W[m+1, n-1] - X[n, n-1]*W[m, n])/X[n-2, n-1]
140+
end
141+
for m in n-1:N-2
142+
W[m, n-2] = W[n-2, m]
143+
end
144+
end
145+
return GramMatrix(W, X)
146+
end
147+
111148
#
112149
# X'W-W*X = G*J*G'
113150
# This returns G, where J = [0 1; -1 0], respecting the skew-symmetry of the right-hand side.
@@ -216,6 +253,11 @@ function fastcholesky!(L::BandedMatrix{T}, X, G, c, ĉ, l, v, row1, n) where T
216253
L[n, n] = sqrt(c[n])
217254
end
218255

256+
struct ChebyshevGramMatrix{T, V <: AbstractVector{T}} <: AbstractGramMatrix{T}
257+
μ::V
258+
n::Int
259+
end
260+
219261
"""
220262
ChebyshevGramMatrix(μ::AbstractVector)
221263
@@ -232,11 +274,6 @@ Specialized construction and Cholesky factorization is given for this type.
232274
233275
See also [`GramMatrix`](@ref) for the general case.
234276
"""
235-
struct ChebyshevGramMatrix{T, V <: AbstractVector{T}} <: AbstractGramMatrix{T}
236-
μ::V
237-
n::Int
238-
end
239-
240277
function ChebyshevGramMatrix::V) where {T, V <: AbstractVector{T}}
241278
n = (length(μ)+1)÷2
242279
ChebyshevGramMatrix{T, V}(μ, n)

0 commit comments

Comments
 (0)