Skip to content

Commit

Permalink
Deprecate cholfact to cholesky.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacha0 committed May 23, 2018
1 parent 1ca3a36 commit d76d364
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 109 deletions.
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,9 @@ Deprecated or removed
`type` is fully deprecated to `mutable struct` ([#19157], [#20418]).

* `lufact`, `schurfact`, `lqfact`, `qrfact`, `ldltfact`, `svdfact`,
`bkfact`, `hessfact`, and `eigfact` have respectively been deprecated to
`lu`, `schur`, `lq`, `qr`, `ldlt`, `svd`, `bunchkaufman`,
`hessenberg`, and `eigen` ([#27159]).
`bkfact`, `hessfact`, `eigfact`, and `cholfact` have respectively been
deprecated to `lu`, `schur`, `lq`, `qr`, `ldlt`, `svd`, `bunchkaufman`,
`hessenberg`, `eigen`, and `cholesky` ([#27159]).

* `lufact!`, `schurfact!`, `lqfact!`, `qrfact!`, `ldltfact!`, `svdfact!`,
`bkfact!`, `hessfact!`, and `eigfact!` have respectively been deprecated to
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ LinearAlgebra.UniformScaling
LinearAlgebra.lu
LinearAlgebra.lu!
LinearAlgebra.chol
LinearAlgebra.cholfact
LinearAlgebra.cholesky
LinearAlgebra.cholfact!
LinearAlgebra.lowrankupdate
LinearAlgebra.lowrankdowndate
Expand Down
8 changes: 4 additions & 4 deletions stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export
bunchkaufman,
bunchkaufman!,
chol,
cholfact,
cholesky,
cholfact!,
cond,
condskeel,
Expand Down Expand Up @@ -250,7 +250,7 @@ end
Compute `A \\ B` in-place and store the result in `Y`, returning the result.
The argument `A` should *not* be a matrix. Rather, instead of matrices it should be a
factorization object (e.g. produced by [`factorize`](@ref) or [`cholfact`](@ref)).
factorization object (e.g. produced by [`factorize`](@ref) or [`cholesky`](@ref)).
The reason for this is that factorization itself is both expensive and typically allocates memory
(although it can also be done in-place via, e.g., [`lu!`](@ref)),
and performance-critical situations requiring `ldiv!` usually also require fine-grained
Expand All @@ -264,7 +264,7 @@ ldiv!(Y, A, B)
Compute `A \\ B` in-place and overwriting `B` to store the result.
The argument `A` should *not* be a matrix. Rather, instead of matrices it should be a
factorization object (e.g. produced by [`factorize`](@ref) or [`cholfact`](@ref)).
factorization object (e.g. produced by [`factorize`](@ref) or [`cholesky`](@ref)).
The reason for this is that factorization itself is both expensive and typically allocates memory
(although it can also be done in-place via, e.g., [`lu!`](@ref)),
and performance-critical situations requiring `ldiv!` usually also require fine-grained
Expand All @@ -279,7 +279,7 @@ ldiv!(A, B)
Compute `A / B` in-place and overwriting `A` to store the result.
The argument `B` should *not* be a matrix. Rather, instead of matrices it should be a
factorization object (e.g. produced by [`factorize`](@ref) or [`cholfact`](@ref)).
factorization object (e.g. produced by [`factorize`](@ref) or [`cholesky`](@ref)).
The reason for this is that factorization itself is both expensive and typically allocates memory
(although it can also be done in-place via, e.g., [`lu!`](@ref)),
and performance-critical situations requiring `rdiv!` usually also require fine-grained
Expand Down
34 changes: 17 additions & 17 deletions stdlib/LinearAlgebra/src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# Cholesky Factorization #
##########################

# The dispatch structure in the chol!, chol, cholfact, and cholfact! methods is a bit
# The dispatch structure in the chol!, chol, cholesky, and cholfact! methods is a bit
# complicated and some explanation is therefore provided in the following
#
# In the methods below, LAPACK is called when possible, i.e. StridedMatrices with Float32,
# Float64, Complex{Float32}, and Complex{Float64} element types. For other element or
# matrix types, the unblocked Julia implementation in _chol! is used. For cholfact
# matrix types, the unblocked Julia implementation in _chol! is used. For cholesky
# and cholfact! pivoting is supported through a Val(Bool) argument. A type argument is
# necessary for type stability since the output of cholfact and cholfact! is either
# necessary for type stability since the output of cholesky and cholfact! is either
# Cholesky or PivotedCholesky. The latter is only
# supported for the four LAPACK element types. For other types, e.g. BigFloats Val(true) will
# give an error. It is required that the input is Hermitian (including real symmetric) either
Expand All @@ -21,7 +21,7 @@
# The internal structure is as follows
# - _chol! returns the factor and info without checking positive definiteness
# - chol/chol! returns the factor and checks for positive definiteness
# - cholfact/cholfact! returns Cholesky without checking positive definiteness
# - cholesky/cholfact! returns Cholesky without checking positive definiteness

# FixMe? The dispatch below seems overly complicated. One simplification could be to
# merge the two Cholesky types into one. It would remove the need for Val completely but
Expand Down Expand Up @@ -218,7 +218,7 @@ end
"""
cholfact!(A, Val(false)) -> Cholesky
The same as [`cholfact`](@ref), but saves space by overwriting the input `A`,
The same as [`cholesky`](@ref), but saves space by overwriting the input `A`,
instead of creating a copy. An [`InexactError`](@ref) exception is thrown if
the factorization produces a number not representable by the element type of
`A`, e.g. for integer types.
Expand Down Expand Up @@ -263,7 +263,7 @@ cholfact!(A::RealHermSymComplexHerm{<:Real}, ::Val{true}; tol = 0.0) =
"""
cholfact!(A, Val(true); tol = 0.0) -> CholeskyPivoted
The same as [`cholfact`](@ref), but saves space by overwriting the input `A`,
The same as [`cholesky`](@ref), but saves space by overwriting the input `A`,
instead of creating a copy. An [`InexactError`](@ref) exception is thrown if the
factorization produces a number not representable by the element type of `A`,
e.g. for integer types.
Expand All @@ -278,11 +278,11 @@ function cholfact!(A::StridedMatrix, ::Val{true}; tol = 0.0)
end
end

# cholfact. Non-destructive methods for computing Cholesky factorization of real symmetric
# cholesky. Non-destructive methods for computing Cholesky factorization of real symmetric
# or Hermitian matrix
## No pivoting (default)
"""
cholfact(A, Val(false)) -> Cholesky
cholesky(A, Val(false)) -> Cholesky
Compute the Cholesky factorization of a dense symmetric positive definite matrix `A`
and return a `Cholesky` factorization. The matrix `A` can either be a [`Symmetric`](@ref) or [`Hermitian`](@ref)
Expand All @@ -299,7 +299,7 @@ julia> A = [4. 12. -16.; 12. 37. -43.; -16. -43. 98.]
12.0 37.0 -43.0
-16.0 -43.0 98.0
julia> C = cholfact(A)
julia> C = cholesky(A)
Cholesky{Float64,Array{Float64,2}}
U factor:
3×3 UpperTriangular{Float64,Array{Float64,2}}:
Expand All @@ -323,13 +323,13 @@ julia> C.L * C.U == A
true
```
"""
cholfact(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}},
cholesky(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}},
::Val{false}=Val(false)) = cholfact!(cholcopy(A))


## With pivoting
"""
cholfact(A, Val(true); tol = 0.0) -> CholeskyPivoted
cholesky(A, Val(true); tol = 0.0) -> CholeskyPivoted
Compute the pivoted Cholesky factorization of a dense symmetric positive semi-definite matrix `A`
and return a `CholeskyPivoted` factorization. The matrix `A` can either be a [`Symmetric`](@ref)
Expand All @@ -340,11 +340,11 @@ The following functions are available for `PivotedCholesky` objects:
The argument `tol` determines the tolerance for determining the rank.
For negative values, the tolerance is the machine precision.
"""
cholfact(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}},
cholesky(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}},
::Val{true}; tol = 0.0) = cholfact!(cholcopy(A), Val(true); tol = tol)

## Number
function cholfact(x::Number, uplo::Symbol=:U)
function cholesky(x::Number, uplo::Symbol=:U)
C, info = _chol!(x, uplo)
xf = fill(C, 1, 1)
Cholesky(xf, uplo, info)
Expand Down Expand Up @@ -557,7 +557,7 @@ rank(C::CholeskyPivoted) = C.rank
lowrankupdate!(C::Cholesky, v::StridedVector) -> CC::Cholesky
Update a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U` then
`CC = cholfact(C.U'C.U + v*v')` but the computation of `CC` only uses `O(n^2)`
`CC = cholesky(C.U'C.U + v*v')` but the computation of `CC` only uses `O(n^2)`
operations. The input factorization `C` is updated in place such that on exit `C == CC`.
The vector `v` is destroyed during the computation.
"""
Expand Down Expand Up @@ -603,7 +603,7 @@ end
lowrankdowndate!(C::Cholesky, v::StridedVector) -> CC::Cholesky
Downdate a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U` then
`CC = cholfact(C.U'C.U - v*v')` but the computation of `CC` only uses `O(n^2)`
`CC = cholesky(C.U'C.U - v*v')` but the computation of `CC` only uses `O(n^2)`
operations. The input factorization `C` is updated in place such that on exit `C == CC`.
The vector `v` is destroyed during the computation.
"""
Expand Down Expand Up @@ -656,7 +656,7 @@ end
lowrankupdate(C::Cholesky, v::StridedVector) -> CC::Cholesky
Update a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U`
then `CC = cholfact(C.U'C.U + v*v')` but the computation of `CC` only uses
then `CC = cholesky(C.U'C.U + v*v')` but the computation of `CC` only uses
`O(n^2)` operations.
"""
lowrankupdate(C::Cholesky, v::StridedVector) = lowrankupdate!(copy(C), copy(v))
Expand All @@ -665,7 +665,7 @@ lowrankupdate(C::Cholesky, v::StridedVector) = lowrankupdate!(copy(C), copy(v))
lowrankdowndate(C::Cholesky, v::StridedVector) -> CC::Cholesky
Downdate a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U`
then `CC = cholfact(C.U'C.U - v*v')` but the computation of `CC` only uses
then `CC = cholesky(C.U'C.U - v*v')` but the computation of `CC` only uses
`O(n^2)` operations.
"""
lowrankdowndate(C::Cholesky, v::StridedVector) = lowrankdowndate!(copy(C), copy(v))
6 changes: 3 additions & 3 deletions stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ julia> isposdef(A)
true
```
"""
isposdef(A::AbstractMatrix) = ishermitian(A) && isposdef(cholfact(Hermitian(A)))
isposdef(A::AbstractMatrix) = ishermitian(A) && isposdef(cholesky(Hermitian(A)))
isposdef(x::Number) = imag(x)==0 && real(x) > 0

# the definition of strides for Array{T,N} is tuple() if N = 0, otherwise it is
Expand Down Expand Up @@ -1112,7 +1112,7 @@ systems. For example: `A=factorize(A); x=A\\b; y=A\\C`.
| Properties of `A` | type of factorization |
|:---------------------------|:-----------------------------------------------|
| Positive-definite | Cholesky (see [`cholfact`](@ref)) |
| Positive-definite | Cholesky (see [`cholesky`](@ref)) |
| Dense Symmetric/Hermitian | Bunch-Kaufman (see [`bunchkaufman`](@ref)) |
| Sparse Symmetric/Hermitian | LDLt (see [`ldlt`](@ref)) |
| Triangular | Triangular |
Expand Down Expand Up @@ -1208,7 +1208,7 @@ function factorize(A::StridedMatrix{T}) where T
return UpperTriangular(A)
end
if herm
cf = cholfact(A)
cf = cholesky(A)
if cf.info == 0
return cf
else
Expand Down
7 changes: 7 additions & 0 deletions stdlib/LinearAlgebra/src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using Base: @deprecate, depwarn
@deprecate cond(F::LinearAlgebra.LU, p::Integer) cond(convert(AbstractArray, F), p)

# PR #22188
export cholfact
@deprecate cholfact!(A::StridedMatrix, uplo::Symbol, ::Type{Val{false}}) cholfact!(Hermitian(A, uplo), Val(false))
@deprecate cholfact!(A::StridedMatrix, uplo::Symbol) cholfact!(Hermitian(A, uplo))
@deprecate cholfact(A::StridedMatrix, uplo::Symbol, ::Type{Val{false}}) cholfact(Hermitian(A, uplo), Val(false))
Expand Down Expand Up @@ -1395,3 +1396,9 @@ export eigfact!
@deprecate(eigfact!(A::RealHermSymComplexHerm{T,<:StridedMatrix}, vl::Real, vh::Real) where {T<:BlasReal}, eigen!(A, vl, vh))
@deprecate(eigfact!(A::HermOrSym{T,S}, B::HermOrSym{T,S}) where {T<:BlasReal,S<:StridedMatrix}, eigen!(A, B))
@deprecate(eigfact!(A::Hermitian{T,S}, B::Hermitian{T,S}) where {T<:BlasComplex,S<:StridedMatrix}, eigen!(A, B))

# deprecate cholfact to cholesky
# cholfact exported from deprecation above
@deprecate(cholfact(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}}, ::Val{false}=Val(false)), cholesky(A, Val(false)))
@deprecate(cholfact(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}}, ::Val{true}; tol = 0.0), cholesky(A, Val(true); tol=tol))
@deprecate(cholfact(x::Number, uplo::Symbol=:U), cholesky(x, uplo))
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
Test that a factorization of a matrix succeeded.
```jldoctest
julia> F = cholfact([1 0; 0 1]);
julia> F = cholesky([1 0; 0 1]);
julia> LinearAlgebra.issuccess(F)
true
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/test/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ end

@testset "test example due to @timholy in PR 15354" begin
A = rand(6,5); A = complex(A'*A) # to avoid calling the real-lhs-complex-rhs method
F = cholfact(A);
F = cholesky(A);
v6 = rand(ComplexF64, 6)
v5 = view(v6, 1:5)
@test F\v5 == F\v6[1:5]
Expand Down
Loading

0 comments on commit d76d364

Please sign in to comment.