diff --git a/src/banded/BandedLU.jl b/src/banded/BandedLU.jl index 4f330f95..1af01e98 100644 --- a/src/banded/BandedLU.jl +++ b/src/banded/BandedLU.jl @@ -32,9 +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 -if !(isdefined(LinearAlgebra, :AdjointFactorization)) # VERSION < v"1.10-" - adjoint(F::BandedLU) = Adjoint(F) -end transpose(F::BandedLU) = TransposeFact(F) lu(S::BandedLU) = S diff --git a/src/generic/AbstractBandedMatrix.jl b/src/generic/AbstractBandedMatrix.jl index f3e54478..af3ba97e 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..d54ba0f8 100644 --- a/src/symbanded/SplitCholesky.jl +++ b/src/symbanded/SplitCholesky.jl @@ -54,13 +54,9 @@ 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 +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) 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_broadcasting.jl b/test/test_broadcasting.jl index 1512ada0..1a85cccc 100644 --- a/test/test_broadcasting.jl +++ b/test/test_broadcasting.jl @@ -42,7 +42,6 @@ Random.seed!(0) @test 1 .+ A isa BandedMatrix @test (1 .+ A) == 1 .+ Matrix(A) @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..7a579e20 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)} @@ -464,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