Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/banded/BandedLU.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/generic/AbstractBandedMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
10 changes: 3 additions & 7 deletions src/symbanded/SplitCholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/test_banded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
1 change: 0 additions & 1 deletion test/test_broadcasting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
41 changes: 25 additions & 16 deletions test/test_symbanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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;])
Expand All @@ -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)}
Expand Down Expand Up @@ -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
Loading