Skip to content

Commit

Permalink
Fix layout of cholesky(Symmetric(view(BandedMatrix))) (#451)
Browse files Browse the repository at this point in the history
* Fix 450

* Change tests for LTS

* Change tests for LTS

* Should also test that U is actually correct

* Fix check of LTS
  • Loading branch information
DanielVandH authored Aug 19, 2024
1 parent c31e007 commit d8e10c7
Show file tree
Hide file tree
Showing 3 changed files with 20 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 = "BandedMatrices"
uuid = "aae01518-5342-5314-be14-df237901396f"
version = "1.7.2"
version = "1.7.3"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
2 changes: 2 additions & 0 deletions src/symbanded/BandedCholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,7 @@ ArrayLayouts._cholesky(::Union{SymmetricLayout{<:AbstractBandedLayout},Hermitian

cholcopy(A::RealHermSymComplexHerm{<:Any,<:BandedMatrix}) =
copyto!(similar(A, LinearAlgebra.choltype(A)), A)
cholcopy(A::RealHermSymComplexHerm{<:Any,<:SubArray{<:Number, 2, <:BandedMatrix}}) =
copyto!(similar(A, LinearAlgebra.choltype(A)), A)
# cholesky(A::Hermitian{T,<:BandedMatrix{T}},
# ::Val{false}=Val(false); check::Bool = true) where T = cholesky!(cholcopy(A); check = check)
17 changes: 17 additions & 0 deletions test/test_symbanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,23 @@ end
@test isposdef(B) == isposdef(Matrix(B)) == false
B = BandedMatrix(1=>Float64[1:4;], 0=>Float64[2:2:10;], -1=>Float64[1:4;])
@test isposdef(B) == isposdef(Matrix(B)) == true

@testset "Issue #450: Cholesky of a BandedMatrix's view" begin
L = brand(10, 10, 2, 0)
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 isbanded(chol.U)
cc = LinearAlgebra.cholcopy(Bv)
@test cc isa Symmetric{Float64, typeof(B)}
@test chol.U cholesky(Matrix(B)).U
@test cc == B
end
end

end # module

2 comments on commit d8e10c7

@dlfivefifty
Copy link
Member

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/113397

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 v1.7.3 -m "<description of version>" d8e10c7edead31916ab2d970b338438033022119
git push origin v1.7.3

Please sign in to comment.