Skip to content

Commit

Permalink
reinstate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelSlevinsky committed Dec 13, 2024
1 parent 0c5cc86 commit 5260921
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FastTransforms"
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
version = "0.16.7"
version = "0.16.8"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
87 changes: 87 additions & 0 deletions test/grammatrixtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using FastTransforms, BandedMatrices, LazyArrays, LinearAlgebra, Test

@testset "GramMatrix" begin
n = 128
for T in (Float32, Float64, BigFloat)
R = plan_leg2cheb(T, n; normcheb=true)*I
X = Tridiagonal([T(n)/(2n-1) for n in 1:n-1], zeros(T, n), [T(n)/(2n+1) for n in 1:n-1]) # Legendre X
W = Symmetric(R'R)
G = GramMatrix(W, X)
F = cholesky(G)
@test F.L*F.L' W
@test F.U R

R = plan_leg2cheb(T, n; normcheb=true, normleg=true)*I
X = SymTridiagonal(zeros(T, n), [sqrt(T(n)^2/(4*n^2-1)) for n in 1:n-1]) # normalized Legendre X
W = Symmetric(R'R)
G = GramMatrix(W, X)
F = cholesky(G)
@test F.L*F.L' W
@test F.U R

b = 4
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
W = I+X^2+X^4
W = Symmetric(W[1:n, 1:n])
X = BandedMatrix(SymTridiagonal(zeros(T, n), [sqrt(T(n)^2/(4*n^2-1)) for n in 1:n-1])) # normalized Legendre X
G = GramMatrix(W, X)
@test bandwidths(G) == (b, b)
F = cholesky(G)
@test F.L*F.L' W

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
W = I+X^2+X^4
W = Symmetric(W[1:n, 1:n])
X = BandedMatrix(SymTridiagonal(T[2n-1 for n in 1:n], T[-n for n in 1:n-1])) # Laguerre X
G = GramMatrix(W, X)
@test bandwidths(G) == (b, b)
F = cholesky(G)
@test F.L*F.L' W
end
W = reshape([i for i in 1.0:n^2], n, n)
X = reshape([i for i in 1.0:4n^2], 2n, 2n)
@test_throws "different sizes" GramMatrix(W, X)
X = X[1:n, 1:n]
@test_throws "nonsymmetric" GramMatrix(W, X)
@test_throws "nontridiagonal" GramMatrix(Symmetric(W), X)
end

@testset "ChebyshevGramMatrix" begin
n = 128
for T in (Float32, Float64, BigFloat)
μ = FastTransforms.chebyshevmoments1(T, 2n-1)
G = ChebyshevGramMatrix(μ)
F = cholesky(G)
@test F.L*F.L' G
R = plan_cheb2leg(T, n; normleg=true)*I
@test F.U R

α, β = (T(0.123), T(0.456))
μ = FastTransforms.chebyshevjacobimoments1(T, 2n-1, α, β)
G = ChebyshevGramMatrix(μ)
F = cholesky(G)
@test F.L*F.L' G
R = plan_cheb2jac(T, n, α, β; normjac=true)*I
@test F.U R

μ = -FastTransforms.chebyshevlogmoments1(T, 2n-1)
G = ChebyshevGramMatrix(μ)
F = cholesky(G)
@test F.L*F.L' G

μ = FastTransforms.chebyshevabsmoments1(T, 2n-1)
G = ChebyshevGramMatrix(μ)
F = cholesky(G)
@test F.L*F.L' G

μ = PaddedVector(T(1) ./ [1,2,3,4,5], 2n-1)
G = ChebyshevGramMatrix(μ)
@test bandwidths(G) == (4, 4)
F = cholesky(G)
@test F.L*F.L' G
μd = Vector{T}(μ)
Gd = ChebyshevGramMatrix(μd)
Fd = cholesky(Gd)
@test F.L Fd.L
end
end

2 comments on commit 5260921

@MikaelSlevinsky
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/121345

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.16.8 -m "<description of version>" 5260921ef953b357e7eb9a0fd4b0567b4484ef61
git push origin v0.16.8

Please sign in to comment.