Skip to content

Fix incorrect dispatch for Cholesky equality #1404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ end
Base.propertynames(F::Cholesky, private::Bool=false) =
(:U, :L, :UL, (private ? fieldnames(typeof(F)) : ())...)

function Base.:(==)(C1::Cholesky, C2::Cholesky)
function Base.:(==)(C1::C, C2::D) where {C<:Cholesky, D<:Cholesky}
C1.uplo == C2.uplo || return false
C1.uplo == 'L' ? (C1.L == C2.L) : (C1.U == C2.U)
end
Expand Down
16 changes: 16 additions & 0 deletions test/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,22 @@ end
@test C.L == L
@test C.U == L'
end
let
B = [1.0 5.0; 3.0 4.0]
CA = Cholesky(LowerTriangular(A))
CB = Cholesky(LowerTriangular(B))
@test CA == CB
@test CA.L == CB.L
@test CA.U == CB.U
end
let
C = [1.0 2.0; 5.0 4.0]
CA = Cholesky(UpperTriangular(A))
CC = Cholesky(UpperTriangular(C))
@test CA == CC
@test CA.L == CC.L
@test CA.U == CC.U
end
end

@testset "adjoint of Cholesky" begin
Expand Down