From 49478453f516a54eb3b171d746ddeeec9839420a Mon Sep 17 00:00:00 2001 From: MikaelSlevinsky Date: Mon, 4 Nov 2024 12:48:11 -0600 Subject: [PATCH] add a test for nonzero diagonal jacobi matrices --- src/GramMatrix.jl | 4 ++-- test/GramMatrixtests.jl | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/GramMatrix.jl b/src/GramMatrix.jl index 11d23c85..1c438f37 100644 --- a/src/GramMatrix.jl +++ b/src/GramMatrix.jl @@ -56,10 +56,10 @@ GramMatrix(W::WT, X::XT) where {T, WT <: AbstractMatrix{T}, XT <: AbstractMatrix # function compute_skew_generators(W::GramMatrix{T}) where T X = W.X - m, n = size(W) + n = size(W, 1) G = zeros(T, n, 2) G[n, 1] = one(T) - G[:, 2] .= W[n-1, :]*X[n-1, n] - X'W[:, n] + G[:, 2] .= W[n-1, :]*X[n-1, n] + W[n, :]*X[n, n] - X'W[:, n] return G end diff --git a/test/GramMatrixtests.jl b/test/GramMatrixtests.jl index 594e9182..3ac9d626 100644 --- a/test/GramMatrixtests.jl +++ b/test/GramMatrixtests.jl @@ -28,6 +28,15 @@ using FastTransforms, BandedMatrices, LazyArrays, LinearAlgebra, Test @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)