From 1ca3a36997415adf6a107c88aff13c3b7a839a12 Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Tue, 22 May 2018 20:27:22 -0700 Subject: [PATCH] Deprecate eigfact! to eigen!. --- NEWS.md | 4 ++-- stdlib/LinearAlgebra/src/LinearAlgebra.jl | 2 +- stdlib/LinearAlgebra/src/deprecated.jl | 17 +++++++++++++++++ stdlib/LinearAlgebra/src/eigen.jl | 22 +++++++++++----------- stdlib/LinearAlgebra/src/symmetric.jl | 16 ++++++++-------- stdlib/LinearAlgebra/src/tridiag.jl | 12 ++++++------ 6 files changed, 45 insertions(+), 28 deletions(-) diff --git a/NEWS.md b/NEWS.md index 976628e69a0bec..a5fd03a00ca72a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -709,9 +709,9 @@ Deprecated or removed `hessenberg`, and `eigen` ([#27159]). * `lufact!`, `schurfact!`, `lqfact!`, `qrfact!`, `ldltfact!`, `svdfact!`, - `bkfact!`, and `hessfact!` have respectively been deprecated to + `bkfact!`, `hessfact!`, and `eigfact!` have respectively been deprecated to `lu!`, `schur!`, `lq!`, `qr!`, `ldlt!`, `svd!`, `bunchkaufman!`, - and `hessenberg!` ([#27159]). + `hessenberg!`, and `eigen!` ([#27159]). * Indexing into multidimensional arrays with more than one index but fewer indices than there are dimensions is no longer permitted when those trailing dimensions have lengths greater than 1. diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index e68f3c2126676c..a6770d3c6e9600 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -82,7 +82,7 @@ export dot, eig, eigen, - eigfact!, + eigen!, eigmax, eigmin, eigvals, diff --git a/stdlib/LinearAlgebra/src/deprecated.jl b/stdlib/LinearAlgebra/src/deprecated.jl index 08208769bc9ea7..fea7008320ebb8 100644 --- a/stdlib/LinearAlgebra/src/deprecated.jl +++ b/stdlib/LinearAlgebra/src/deprecated.jl @@ -1378,3 +1378,20 @@ export eigfact @deprecate(eigfact(A::RealHermSymComplexHerm, vl::Real, vh::Real), eigen(A, vl, vh)) @deprecate(eigfact(A::AbstractTriangular), eigen(A)) @deprecate(eigfact(D::Diagonal; permute::Bool=true, scale::Bool=true), eigen(D; permute=permute, scale=scale)) + +# deprecate eigfact! to eigen! +export eigfact! +@deprecate(eigfact!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) where T<:BlasReal, eigen!(A; permute=permute, scale=scale)) +@deprecate(eigfact!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) where T<:BlasComplex, eigen!(A; permute=permute, scale=scale)) +@deprecate(eigfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasReal, eigen!(A, B)) +@deprecate(eigfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasComplex, eigen!(A, B)) + +@deprecate(eigfact!(A::SymTridiagonal{<:BlasReal}), eigen!(A)) +@deprecate(eigfact!(A::SymTridiagonal{<:BlasReal}, irange::UnitRange), eigen!(A, irange)) +@deprecate(eigfact!(A::SymTridiagonal{<:BlasReal}, vl::Real, vu::Real), eigen!(A, vl, vu)) + +@deprecate(eigfact!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}), eigen!(A)) +@deprecate(eigfact!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}, irange::UnitRange), eigen!(A, irange)) +@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)) diff --git a/stdlib/LinearAlgebra/src/eigen.jl b/stdlib/LinearAlgebra/src/eigen.jl index 07bc5bafa691d3..d63c79ed90c434 100644 --- a/stdlib/LinearAlgebra/src/eigen.jl +++ b/stdlib/LinearAlgebra/src/eigen.jl @@ -35,15 +35,15 @@ end isposdef(A::Union{Eigen,GeneralizedEigen}) = isreal(A.values) && all(x -> x > 0, A.values) """ - eigfact!(A, [B]) + eigen!(A, [B]) Same as [`eigen`](@ref), but saves space by overwriting the input `A` (and `B`), instead of creating a copy. """ -function eigfact!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) where T<:BlasReal +function eigen!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) where T<:BlasReal n = size(A, 2) n == 0 && return Eigen(zeros(T, 0), zeros(T, 0, 0)) - issymmetric(A) && return eigfact!(Symmetric(A)) + issymmetric(A) && return eigen!(Symmetric(A)) A, WR, WI, VL, VR, _ = LAPACK.geevx!(permute ? (scale ? 'B' : 'P') : (scale ? 'S' : 'N'), 'N', 'V', 'N', A) iszero(WI) && return Eigen(WR, VR) evec = zeros(Complex{T}, n, n) @@ -63,10 +63,10 @@ function eigfact!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) whe return Eigen(complex.(WR, WI), evec) end -function eigfact!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) where T<:BlasComplex +function eigen!(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) where T<:BlasComplex n = size(A, 2) n == 0 && return Eigen(zeros(T, 0), zeros(T, 0, 0)) - ishermitian(A) && return eigfact!(Hermitian(A)) + ishermitian(A) && return eigen!(Hermitian(A)) return Eigen(LAPACK.geevx!(permute ? (scale ? 'B' : 'P') : (scale ? 'S' : 'N'), 'N', 'V', 'N', A)[[2,4]]...) end @@ -122,7 +122,7 @@ true function eigen(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) where T AA = copy_oftype(A, eigtype(T)) isdiag(AA) && return eigen(Diagonal(AA), permute = permute, scale = scale) - return eigfact!(AA, permute = permute, scale = scale) + return eigen!(AA, permute = permute, scale = scale) end eigen(x::Number) = Eigen([x], fill(one(x), 1, 1)) @@ -340,8 +340,8 @@ inv(A::Eigen) = A.vectors * inv(Diagonal(A.values)) / A.vectors det(A::Eigen) = prod(A.values) # Generalized eigenproblem -function eigfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasReal - issymmetric(A) && isposdef(B) && return eigfact!(Symmetric(A), Symmetric(B)) +function eigen!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasReal + issymmetric(A) && isposdef(B) && return eigen!(Symmetric(A), Symmetric(B)) n = size(A, 1) alphar, alphai, beta, _, vr = LAPACK.ggev!('N', 'V', A, B) iszero(alphai) && return GeneralizedEigen(alphar ./ beta, vr) @@ -363,8 +363,8 @@ function eigfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasReal return GeneralizedEigen(complex.(alphar, alphai)./beta, vecs) end -function eigfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasComplex - ishermitian(A) && isposdef(B) && return eigfact!(Hermitian(A), Hermitian(B)) +function eigen!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasComplex + ishermitian(A) && isposdef(B) && return eigen!(Hermitian(A), Hermitian(B)) alpha, beta, _, vr = LAPACK.ggev!('N', 'V', A, B) return GeneralizedEigen(alpha./beta, vr) end @@ -411,7 +411,7 @@ true """ function eigen(A::AbstractMatrix{TA}, B::AbstractMatrix{TB}) where {TA,TB} S = promote_type(eigtype(TA),TB) - return eigfact!(copy_oftype(A, S), copy_oftype(B, S)) + return eigen!(copy_oftype(A, S), copy_oftype(B, S)) end eigen(A::Number, B::Number) = eigen(fill(A,1,1), fill(B,1,1)) diff --git a/stdlib/LinearAlgebra/src/symmetric.jl b/stdlib/LinearAlgebra/src/symmetric.jl index 3a0bcf2a2871ab..1760a16c084325 100644 --- a/stdlib/LinearAlgebra/src/symmetric.jl +++ b/stdlib/LinearAlgebra/src/symmetric.jl @@ -474,15 +474,15 @@ end inv(A::Hermitian{<:Any,<:StridedMatrix}) = Hermitian(_inv(A), Symbol(A.uplo)) inv(A::Symmetric{<:Any,<:StridedMatrix}) = Symmetric(_inv(A), Symbol(A.uplo)) -eigfact!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}) = Eigen(LAPACK.syevr!('V', 'A', A.uplo, A.data, 0.0, 0.0, 0, 0, -1.0)...) +eigen!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}) = Eigen(LAPACK.syevr!('V', 'A', A.uplo, A.data, 0.0, 0.0, 0, 0, -1.0)...) function eigen(A::RealHermSymComplexHerm) T = eltype(A) S = eigtype(T) - eigfact!(S != T ? convert(AbstractMatrix{S}, A) : copy(A)) + eigen!(S != T ? convert(AbstractMatrix{S}, A) : copy(A)) end -eigfact!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}, irange::UnitRange) = Eigen(LAPACK.syevr!('V', 'I', A.uplo, A.data, 0.0, 0.0, irange.start, irange.stop, -1.0)...) +eigen!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}, irange::UnitRange) = Eigen(LAPACK.syevr!('V', 'I', A.uplo, A.data, 0.0, 0.0, irange.start, irange.stop, -1.0)...) """ eigen(A::Union{SymTridiagonal, Hermitian, Symmetric}, irange::UnitRange) -> Eigen @@ -504,10 +504,10 @@ The `UnitRange` `irange` specifies indices of the sorted eigenvalues to search f function eigen(A::RealHermSymComplexHerm, irange::UnitRange) T = eltype(A) S = eigtype(T) - eigfact!(S != T ? convert(AbstractMatrix{S}, A) : copy(A), irange) + eigen!(S != T ? convert(AbstractMatrix{S}, A) : copy(A), irange) end -eigfact!(A::RealHermSymComplexHerm{T,<:StridedMatrix}, vl::Real, vh::Real) where {T<:BlasReal} = +eigen!(A::RealHermSymComplexHerm{T,<:StridedMatrix}, vl::Real, vh::Real) where {T<:BlasReal} = Eigen(LAPACK.syevr!('V', 'V', A.uplo, A.data, convert(T, vl), convert(T, vh), 0, 0, -1.0)...) """ @@ -530,7 +530,7 @@ The following functions are available for `Eigen` objects: [`inv`](@ref), [`det` function eigen(A::RealHermSymComplexHerm, vl::Real, vh::Real) T = eltype(A) S = eigtype(T) - eigfact!(S != T ? convert(AbstractMatrix{S}, A) : copy(A), vl, vh) + eigen!(S != T ? convert(AbstractMatrix{S}, A) : copy(A), vl, vh) end eigvals!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}) = @@ -624,11 +624,11 @@ end eigmax(A::RealHermSymComplexHerm{<:Real,<:StridedMatrix}) = eigvals(A, size(A, 1):size(A, 1))[1] eigmin(A::RealHermSymComplexHerm{<:Real,<:StridedMatrix}) = eigvals(A, 1:1)[1] -function eigfact!(A::HermOrSym{T,S}, B::HermOrSym{T,S}) where {T<:BlasReal,S<:StridedMatrix} +function eigen!(A::HermOrSym{T,S}, B::HermOrSym{T,S}) where {T<:BlasReal,S<:StridedMatrix} vals, vecs, _ = LAPACK.sygvd!(1, 'V', A.uplo, A.data, B.uplo == A.uplo ? B.data : copy(B.data')) GeneralizedEigen(vals, vecs) end -function eigfact!(A::Hermitian{T,S}, B::Hermitian{T,S}) where {T<:BlasComplex,S<:StridedMatrix} +function eigen!(A::Hermitian{T,S}, B::Hermitian{T,S}) where {T<:BlasComplex,S<:StridedMatrix} vals, vecs, _ = LAPACK.sygvd!(1, 'V', A.uplo, A.data, B.uplo == A.uplo ? B.data : copy(B.data')) GeneralizedEigen(vals, vecs) end diff --git a/stdlib/LinearAlgebra/src/tridiag.jl b/stdlib/LinearAlgebra/src/tridiag.jl index 6e5bd0baa3051f..a5e7a053184af6 100644 --- a/stdlib/LinearAlgebra/src/tridiag.jl +++ b/stdlib/LinearAlgebra/src/tridiag.jl @@ -183,18 +183,18 @@ end (\)(T::SymTridiagonal, B::StridedVecOrMat) = ldlt(T)\B -eigfact!(A::SymTridiagonal{<:BlasReal}) = Eigen(LAPACK.stegr!('V', A.dv, A.ev)...) -eigen(A::SymTridiagonal{T}) where T = eigfact!(copy_oftype(A, eigtype(T))) +eigen!(A::SymTridiagonal{<:BlasReal}) = Eigen(LAPACK.stegr!('V', A.dv, A.ev)...) +eigen(A::SymTridiagonal{T}) where T = eigen!(copy_oftype(A, eigtype(T))) -eigfact!(A::SymTridiagonal{<:BlasReal}, irange::UnitRange) = +eigen!(A::SymTridiagonal{<:BlasReal}, irange::UnitRange) = Eigen(LAPACK.stegr!('V', 'I', A.dv, A.ev, 0.0, 0.0, irange.start, irange.stop)...) eigen(A::SymTridiagonal{T}, irange::UnitRange) where T = - eigfact!(copy_oftype(A, eigtype(T)), irange) + eigen!(copy_oftype(A, eigtype(T)), irange) -eigfact!(A::SymTridiagonal{<:BlasReal}, vl::Real, vu::Real) = +eigen!(A::SymTridiagonal{<:BlasReal}, vl::Real, vu::Real) = Eigen(LAPACK.stegr!('V', 'V', A.dv, A.ev, vl, vu, 0, 0)...) eigen(A::SymTridiagonal{T}, vl::Real, vu::Real) where T = - eigfact!(copy_oftype(A, eigtype(T)), vl, vu) + eigen!(copy_oftype(A, eigtype(T)), vl, vu) eigvals!(A::SymTridiagonal{<:BlasReal}) = LAPACK.stev!('N', A.dv, A.ev)[1] eigvals(A::SymTridiagonal{T}) where T = eigvals!(copy_oftype(A, eigtype(T)))