Skip to content

Commit

Permalink
add issuccess for CholeskyPivoted (#36002)
Browse files Browse the repository at this point in the history
* add issuccess for CholeskyPivoted

* add tests, NEWS and compat
  • Loading branch information
palday committed May 24, 2020
1 parent 0413ef0 commit 1747eac
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Standard library changes
* All `AbstractUnitRange{<:Integer}`s now work with `SubString`, `view`, `@view` and `@views` on strings ([#35879]).

#### LinearAlgebra

* New method `LinearAlgebra.issuccess(::CholeskyPivoted)` for checking whether pivoted Cholesky factorization was successful ([#36002]).

#### Markdown

Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ end
Base.propertynames(F::CholeskyPivoted, private::Bool=false) =
(:U, :L, :p, :P, (private ? fieldnames(typeof(F)) : ())...)

issuccess(C::Cholesky) = C.info == 0
issuccess(C::Union{Cholesky,CholeskyPivoted}) = C.info == 0

function show(io::IO, mime::MIME{Symbol("text/plain")}, C::Cholesky{<:Any,<:AbstractMatrix})
if issuccess(C)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ checknonsingular(info) = checknonsingular(info, Val{true}())
Test that a factorization of a matrix succeeded.
!!! compat "Julia 1.6"
`issuccess(::CholeskyPivoted)` requires Julia 1.6 or later.
```jldoctest
julia> F = cholesky([1 0; 0 1]);
Expand Down
2 changes: 2 additions & 0 deletions stdlib/LinearAlgebra/test/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ end
@test_throws RankDeficientException cholesky!(copy(M), Val(true))
@test_throws RankDeficientException cholesky(M, Val(true); check = true)
@test_throws RankDeficientException cholesky!(copy(M), Val(true); check = true)
@test !LinearAlgebra.issuccess(cholesky(M, Val(true); check = false))
@test !LinearAlgebra.issuccess(cholesky!(copy(M), Val(true); check = false))
C = cholesky(M, Val(true); check = false)
@test_throws RankDeficientException chkfullrank(C)
C = cholesky!(copy(M), Val(true); check = false)
Expand Down

0 comments on commit 1747eac

Please sign in to comment.