Skip to content

Commit bc82c1f

Browse files
committed
Don't require the moments to be a full vector
1 parent a40b3dc commit bc82c1f

File tree

4 files changed

+21
-33
lines changed

4 files changed

+21
-33
lines changed

Project.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name = "FastTransforms"
22
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
3-
version = "0.17"
4-
3+
version = "0.18.0"
54

65
[deps]
76
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -19,6 +18,13 @@ RecurrenceRelationships = "807425ed-42ea-44d6-a357-6771516d7b2c"
1918
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2019
ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24"
2120

21+
[weakdeps]
22+
InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
23+
24+
[extensions]
25+
FastTransformsInfiniteArraysExt = "InfiniteArrays"
26+
27+
2228
[compat]
2329
AbstractFFTs = "1.0"
2430
ArrayLayouts = "1.10"
@@ -28,15 +34,17 @@ FastGaussQuadrature = "0.4, 0.5, 1"
2834
FastTransforms_jll = "0.6.2"
2935
FillArrays = "0.9, 0.10, 0.11, 0.12, 0.13, 1"
3036
GenericFFT = "0.1"
37+
InfiniteArrays = "0.15"
3138
LazyArrays = "2.2"
3239
RecurrenceRelationships = "0.2"
3340
SpecialFunctions = "0.10, 1, 2"
3441
ToeplitzMatrices = "0.7.1, 0.8"
35-
julia = "1.7"
42+
julia = "1.10"
3643

3744
[extras]
45+
InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
3846
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3947
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4048

4149
[targets]
42-
test = ["Test", "Random"]
50+
test = ["InfiniteArrays", "Random", "Test"]

src/GramMatrix.jl

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,13 @@ In the standard (classical) normalization, ``p_0(x) = 1``, so that the moments
5959
The recurrence is built from ``X^\\top W = WX``.
6060
"""
6161
GramMatrix::AbstractVector{T}, X::XT) where {T, XT <: AbstractMatrix{T}} = GramMatrix(μ, X, one(T))
62-
function GramMatrix::AbstractVector{T}, X::XT, p0::T) where {T, XT <: AbstractMatrix{T}}
63-
N = length(μ)
64-
n = (N+1)÷2
65-
@assert N == size(X, 1) == size(X, 2)
66-
@assert bandwidths(X) == (1, 1)
67-
W = LowerTriangular(Matrix{T}(undef, N, N))
68-
if n > 0
69-
@inbounds for m in 1:N
70-
W[m, 1] = p0*μ[m]
71-
end
72-
end
73-
if n > 1
74-
@inbounds for m in 2:N-1
75-
W[m, 2] = (X[m-1, m]*W[m-1, 1] + (X[m, m]-X[1, 1])*W[m, 1] + X[m+1, m]*W[m+1, 1])/X[2, 1]
76-
end
77-
end
78-
@inbounds @simd for n in 3:n
79-
for m in n:N-n+1
80-
W[m, n] = (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-2, n-1]*W[m, n-2])/X[n, n-1]
81-
end
82-
end
83-
return GramMatrix(Symmetric(W[1:n, 1:n], :L), eval(XT.name.name)(view(X, 1:n, 1:n)))
84-
end
8562

86-
function GramMatrix::PaddedVector{T}, X::XT, p0::T) where {T, XT <: AbstractMatrix{T}}
87-
N = length(μ)
88-
b = length.args[2])-1
63+
64+
function GramMatrix::AbstractVector{T}, X::XT, p0::T) where {T, XT <: AbstractMatrix{T}}
65+
N = size(X, 1)
66+
b = length(μ)-1
8967
n = (N+1)÷2
90-
@assert N == size(X, 1) == size(X, 2)
68+
@assert N == size(X, 2)
9169
@assert bandwidths(X) == (1, 1)
9270
W = BandedMatrix{T}(undef, (N, N), (b, 0))
9371
if n > 0

test/grammatrixtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ using FastTransforms, BandedMatrices, LazyArrays, LinearAlgebra, Test
2323
X = BandedMatrix(SymTridiagonal(zeros(T, n+b), [sqrt(T(n)^2/(4*n^2-1)) for n in 1:n+b-1])) # normalized Legendre X
2424
W = I+X^2+X^4
2525
W = Symmetric(W[1:n, 1:n])
26-
X = BandedMatrix(SymTridiagonal(zeros(T, n), [sqrt(T(n)^2/(4*n^2-1)) for n in 1:n-1])) # normalized Legendre X
27-
G = GramMatrix(W, X)
26+
= BandedMatrix(SymTridiagonal(zeros(T, n), [sqrt(T(n)^2/(4*n^2-1)) for n in 1:n-1])) # normalized Legendre X
27+
G = GramMatrix(W, )
2828
@test bandwidths(G) == (b, b)
2929
F = cholesky(G)
3030
@test F.L*F.L' W
3131

32+
@test G[1:66,1:66] GramMatrix(W[1:5, 1], X)
33+
3234
X = BandedMatrix(SymTridiagonal(T[2n-1 for n in 1:n+b], T[-n for n in 1:n+b-1])) # Laguerre X, tests nonzero diagonal
3335
W = I+X^2+X^4
3436
W = Symmetric(W[1:n, 1:n])

test/inffasttransformstests.jl

Whitespace-only changes.

0 commit comments

Comments
 (0)