From 5ec2a89c33006a5a6324ce16cf93af1bd164befb Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Tue, 16 Dec 2025 10:40:56 +0000 Subject: [PATCH 1/4] Drop old version checking --- src/banded/BandedLU.jl | 4 +--- src/generic/AbstractBandedMatrix.jl | 7 +++---- src/symbanded/SplitCholesky.jl | 8 +------- test/test_broadcasting.jl | 5 +---- test/test_symbanded.jl | 29 +++++++++++++---------------- 5 files changed, 19 insertions(+), 34 deletions(-) diff --git a/src/banded/BandedLU.jl b/src/banded/BandedLU.jl index 4f330f95..979e5c21 100644 --- a/src/banded/BandedLU.jl +++ b/src/banded/BandedLU.jl @@ -32,9 +32,7 @@ Base.iterate(S::BandedLU, ::Val{:U}) = (S.U, Val(:p)) Base.iterate(S::BandedLU, ::Val{:p}) = (S.p, Val(:done)) Base.iterate(S::BandedLU, ::Val{:done}) = nothing -if !(isdefined(LinearAlgebra, :AdjointFactorization)) # VERSION < v"1.10-" - adjoint(F::BandedLU) = Adjoint(F) -end +adjoint(F::BandedLU) = Adjoint(F) transpose(F::BandedLU) = TransposeFact(F) lu(S::BandedLU) = S diff --git a/src/generic/AbstractBandedMatrix.jl b/src/generic/AbstractBandedMatrix.jl index 865fa180..db026bc9 100644 --- a/src/generic/AbstractBandedMatrix.jl +++ b/src/generic/AbstractBandedMatrix.jl @@ -332,10 +332,9 @@ end #### bandwidths(A::AdjOrTrans{T,S}) where {T,S} = reverse(bandwidths(parent(A))) -if VERSION >= v"1.9" - copy(A::Adjoint{T,<:AbstractBandedMatrix}) where T = copy(parent(A))' - copy(A::Transpose{T,<:AbstractBandedMatrix}) where T = transpose(copy(parent(A))) -end +copy(A::Adjoint{T,<:AbstractBandedMatrix}) where T = copy(parent(A))' +copy(A::Transpose{T,<:AbstractBandedMatrix}) where T = transpose(copy(parent(A))) + function sum!(ret::AbstractArray, A::AbstractBandedMatrix) #Behaves similarly to Base.sum! diff --git a/src/symbanded/SplitCholesky.jl b/src/symbanded/SplitCholesky.jl index 6b3a820f..d3c9dfdf 100644 --- a/src/symbanded/SplitCholesky.jl +++ b/src/symbanded/SplitCholesky.jl @@ -54,13 +54,7 @@ function splitcholesky!(::HermitianLayout{<:BandedColumnMajor}, SplitCholesky(A, A.uplo) end -if !(isdefined(LinearAlgebra, :AdjointFactorization)) # VERSION < v"1.10-" - adjoint(S::SplitCholesky) = Adjoint(S) -else - transpose(S::SplitCholesky{<:Real}) = S' - transpose(::SplitCholesky) = - throw(ArgumentError("transpose of SplitCholesky decomposition is not supported, consider using adjoint")) -end +adjoint(S::SplitCholesky) = Adjoint(S) function lmul!(S::SplitCholesky{T,<:HermOrSym{T,M}}, B::AbstractVecOrMat{T}) where {T<:Real,M<:BandedMatrix{T}} require_one_based_indexing(B) diff --git a/test/test_broadcasting.jl b/test/test_broadcasting.jl index 2d3e227d..3cb87d9f 100644 --- a/test/test_broadcasting.jl +++ b/test/test_broadcasting.jl @@ -41,10 +41,7 @@ Random.seed!(0) @test 1 .+ A == 1 .+ Matrix(A) @test 1 .+ A isa BandedMatrix @test (1 .+ A) == 1 .+ Matrix(A) - - if VERSION ≥ v"1.10" # avoid failure on CI with Mac OS Julia v1.6 - @test 1 .\ A == 1 .\ Matrix(A) - end + @test 1 .\ A == 1 .\ Matrix(A) @test 1 .\ A isa BandedMatrix @test bandwidths(1 .\ A) == bandwidths(A) diff --git a/test/test_symbanded.jl b/test/test_symbanded.jl index a8362025..7aa709cc 100644 --- a/test/test_symbanded.jl +++ b/test/test_symbanded.jl @@ -348,14 +348,13 @@ end B = sbmatrix(W, T, Ub, wb, n) AM, BM = Matrix.((A,B)) @test eigvals(A, B) ≈ eigvals(AM, BM) - if VERSION >= v"1.9" - Λ, V = eigen(A, B) - VM = Matrix(V) - Λ2, V2 = eigen(AM, BM) - @test Λ ≈ Λ2 - @test VM' * AM * VM ≈ V2' * AM * V2 - @test VM' * AM * VM ≈ VM' * BM * VM * Diagonal(Λ) - end + + Λ, V = eigen(A, B) + VM = Matrix(V) + Λ2, V2 = eigen(AM, BM) + @test Λ ≈ Λ2 + @test VM' * AM * VM ≈ V2' * AM * V2 + @test VM' * AM * VM ≈ VM' * BM * VM * Diagonal(Λ) end end @@ -370,7 +369,7 @@ end b = rand(T,size(A,1)) @test Ac\b ≈ Matrix(A)\b - VERSION >= v"1.9-" && @test Ac\b ≈ A\b + @test Ac\b ≈ A\b end for T in (Float64, BigFloat) @@ -383,7 +382,7 @@ end b = rand(T,size(A,1)) @test Ac\b ≈ Matrix(A)\b - VERSION >= v"1.9-" && @test Ac\b ≈ A\b + @test Ac\b ≈ A\b end let T = ComplexF64 @@ -396,7 +395,7 @@ end b = rand(T,size(A,1)) @test Ac\b ≈ Matrix(A)\b - VERSION >= v"1.9-" && @test Ac\b ≈ A\b + @test Ac\b ≈ A\b end B = BandedMatrix(1=>Float64[1:4;], 0=>Float64[1:5;], -1=>Float64[1:4;]) @@ -409,11 +408,9 @@ end B = BandedMatrix(Symmetric(L * L')); Bv = Symmetric(view(B, :, :)) chol = cholesky(Bv) - if VERSION >= v"1.7" - @test MemoryLayout(chol.U) isa TriangularLayout{'U', 'N', typeof(MemoryLayout(B))} - @test MemoryLayout(chol.L) isa TriangularLayout{'L', 'N', typeof(MemoryLayout(B'))} - @test isbanded(chol.L) - end + @test MemoryLayout(chol.U) isa TriangularLayout{'U', 'N', typeof(MemoryLayout(B))} + @test MemoryLayout(chol.L) isa TriangularLayout{'L', 'N', typeof(MemoryLayout(B'))} + @test isbanded(chol.L) @test isbanded(chol.U) cc = LinearAlgebra.cholcopy(Bv) @test cc isa Symmetric{Float64, typeof(B)} From 1de3f61c3e21aca54d3ab33e4a6f50aabf51821b Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Tue, 16 Dec 2025 20:33:29 +0000 Subject: [PATCH 2/4] fix overloads --- .github/workflows/downstream.yml | 2 +- src/banded/BandedLU.jl | 1 - src/symbanded/SplitCholesky.jl | 4 +++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 45fded55..c1be7ac1 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -67,7 +67,7 @@ jobs: # force it to use this PR's version of the package Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps Pkg.update() - Pkg.test(; coverage = true, test_args=["--downstream_integration_test"]) # resolver may fail with test time deps + Pkg.test(; coverage = true) # resolver may fail with test time deps catch err err isa Pkg.Resolve.ResolverError || rethrow() # If we can't resolve that means this is incompatible by SemVer and this is fine diff --git a/src/banded/BandedLU.jl b/src/banded/BandedLU.jl index 979e5c21..1af01e98 100644 --- a/src/banded/BandedLU.jl +++ b/src/banded/BandedLU.jl @@ -32,7 +32,6 @@ Base.iterate(S::BandedLU, ::Val{:U}) = (S.U, Val(:p)) Base.iterate(S::BandedLU, ::Val{:p}) = (S.p, Val(:done)) Base.iterate(S::BandedLU, ::Val{:done}) = nothing -adjoint(F::BandedLU) = Adjoint(F) transpose(F::BandedLU) = TransposeFact(F) lu(S::BandedLU) = S diff --git a/src/symbanded/SplitCholesky.jl b/src/symbanded/SplitCholesky.jl index d3c9dfdf..d54ba0f8 100644 --- a/src/symbanded/SplitCholesky.jl +++ b/src/symbanded/SplitCholesky.jl @@ -54,7 +54,9 @@ function splitcholesky!(::HermitianLayout{<:BandedColumnMajor}, SplitCholesky(A, A.uplo) end -adjoint(S::SplitCholesky) = Adjoint(S) +transpose(S::SplitCholesky{<:Real}) = S' +transpose(::SplitCholesky) = + throw(ArgumentError("transpose of SplitCholesky decomposition is not supported, consider using adjoint")) function lmul!(S::SplitCholesky{T,<:HermOrSym{T,M}}, B::AbstractVecOrMat{T}) where {T<:Real,M<:BandedMatrix{T}} require_one_based_indexing(B) From d3095c47e7253dbe2c87e888bbe7a6cfca2e708e Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 18 Dec 2025 07:43:10 +0000 Subject: [PATCH 3/4] Update downstream.yml --- .github/workflows/downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index c1be7ac1..45fded55 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -67,7 +67,7 @@ jobs: # force it to use this PR's version of the package Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps Pkg.update() - Pkg.test(; coverage = true) # resolver may fail with test time deps + Pkg.test(; coverage = true, test_args=["--downstream_integration_test"]) # resolver may fail with test time deps catch err err isa Pkg.Resolve.ResolverError || rethrow() # If we can't resolve that means this is incompatible by SemVer and this is fine From 650d3b2cd4b39c9a3dfee167b9dbe30c310ce746 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 18 Dec 2025 15:42:54 +0000 Subject: [PATCH 4/4] increase coverage --- test/test_banded.jl | 2 +- test/test_symbanded.jl | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/test_banded.jl b/test/test_banded.jl index fef85f03..a161752f 100644 --- a/test/test_banded.jl +++ b/test/test_banded.jl @@ -71,7 +71,7 @@ include("mymatrix.jl") @test Matrix(sparse(A)) ≈ Matrix(A) @test Matrix(A') ≈ Matrix(A)' - @test Matrix(transpose(A)) ≈ transpose(Matrix(A)) + @test Matrix(transpose(A)) ≈ copy(transpose(A)) ≈ transpose(Matrix(A)) @test Matrix((A+im*A)') ≈ (Matrix(A)+im*Matrix(A))' @test Matrix(transpose(A+im*A)) ≈ transpose(Matrix(A)+im*Matrix(A)) diff --git a/test/test_symbanded.jl b/test/test_symbanded.jl index 7aa709cc..7a579e20 100644 --- a/test/test_symbanded.jl +++ b/test/test_symbanded.jl @@ -461,4 +461,16 @@ end @test eltype(bandedmatrix) == eltype(matrix) end +@testset "splitcholesky!" begin + for T in (Float32, Float64, ComplexF32, ComplexF64) + A = Hermitian(brand(T, 20, 20, 2, 4) + 10I) + S = BandedMatrices.splitcholesky!(A) + if T <: Real + @test transpose(S) ≡ S' + else + @test_throws ArgumentError transpose(S) + end + end +end + end # module