Skip to content

Commit

Permalink
Deprecate svdfact! to svd!.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacha0 committed May 23, 2018
1 parent a659ee9 commit 1084fb4
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 27 deletions.
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,9 @@ Deprecated or removed
* `lufact`, `schurfact`, `lqfact`, `qrfact`, and `ldltfact` have respectively
been deprecated to `lu`, `schur`, `lq`, `qr`, and `ldlt` ([#27159]).

* `lufact!`, `schurfact!`, `lqfact!`, `qrfact!`,
and `ldltfact!` have respectively been deprecated to `lu!`,
`schur!`, `lq!`, `qr!`, and `ldlt!` ([#27159]).
* `lufact!`, `schurfact!`, `lqfact!`, `qrfact!`, `ldltfact!`, and `svdfact!`
have respectively been deprecated to `lu!`, `schur!`, `lq!`, `qr!`, `ldlt!`,
and `svd!` ([#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.
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 @@ -346,7 +346,7 @@ LinearAlgebra.schur
LinearAlgebra.ordschur
LinearAlgebra.ordschur!
LinearAlgebra.svdfact
LinearAlgebra.svdfact!
LinearAlgebra.svd!
LinearAlgebra.svd
LinearAlgebra.svdvals
LinearAlgebra.svdvals!
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export
schur,
schur!,
svd,
svdfact!,
svd!,
svdfact,
svdvals!,
svdvals,
Expand Down
8 changes: 4 additions & 4 deletions stdlib/LinearAlgebra/src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ similar(B::Bidiagonal, ::Type{T}) where {T} = Bidiagonal(similar(B.dv, T), simil

#Singular values
svdvals!(M::Bidiagonal{<:BlasReal}) = LAPACK.bdsdc!(M.uplo, 'N', M.dv, M.ev)[1]
function svdfact!(M::Bidiagonal{<:BlasReal}; full::Bool = false, thin::Union{Bool,Nothing} = nothing)
function svd!(M::Bidiagonal{<:BlasReal}; full::Bool = false, thin::Union{Bool,Nothing} = nothing)
# DEPRECATION TODO: remove deprecated thin argument and associated logic after 0.7
if thin != nothing
Base.depwarn(string("the `thin` keyword argument in `svdfact!(A; thin = $(thin))` has ",
Base.depwarn(string("the `thin` keyword argument in `svd!(A; thin = $(thin))` has ",
"been deprecated in favor of `full`, which has the opposite meaning, ",
"e.g. `svdfact!(A; full = $(!thin))`."), :svdfact!)
"e.g. `svd!(A; full = $(!thin))`."), :svd!)
full::Bool = !thin
end
d, e, U, Vt, Q, iQ = LAPACK.bdsdc!(M.uplo, 'I', M.dv, M.ev)
Expand All @@ -207,7 +207,7 @@ function svdfact(M::Bidiagonal; full::Bool = false, thin::Union{Bool,Nothing} =
"e.g. `svdfact(A; full = $(!thin))`."), :svdfact)
full::Bool = !thin
end
return svdfact!(copy(M), full = full)
return svd!(copy(M), full = full)
end

####################
Expand Down
9 changes: 8 additions & 1 deletion stdlib/LinearAlgebra/src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Base: @deprecate, depwarn

Expand Down Expand Up @@ -1321,3 +1321,10 @@ export qrfact!
# deprecate ldltfact! to ldlt!
export ldltfact!
@deprecate(ldltfact!(S::SymTridiagonal{T,V}) where {T<:Real,V}, ldlt!(S))

# deprecate svdfact! to svd!
export svdfact!
@deprecate(svdfact!(M::Bidiagonal{<:BlasReal}; full::Bool = false, thin::Union{Bool,Nothing} = nothing), svd!(M; full=full, thin=thin))
@deprecate(svdfact!(A::StridedMatrix{T}; full::Bool = false, thin::Union{Bool,Nothing} = nothing) where T<:BlasFloat, svd!(A; full=full, thin=thin))
@deprecate(svdfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasFloat, svd!(A, B))
@deprecate(svdfact!(A::AbstractTriangular), svd!(A))
26 changes: 13 additions & 13 deletions stdlib/LinearAlgebra/src/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ end
SVD(U::AbstractArray{T}, S::Vector{Tr}, Vt::AbstractArray{T}) where {T,Tr} = SVD{T,Tr,typeof(U)}(U, S, Vt)

"""
svdfact!(A; full::Bool = false) -> SVD
svd!(A; full::Bool = false) -> SVD
`svdfact!` is the same as [`svdfact`](@ref), but saves space by
`svd!` is the same as [`svdfact`](@ref), but saves space by
overwriting the input `A`, instead of creating a copy.
# Examples
Expand All @@ -25,7 +25,7 @@ julia> A = [1. 0. 0. 0. 2.; 0. 0. 3. 0. 0.; 0. 0. 0. 0. 0.; 0. 2. 0. 0. 0.]
0.0 0.0 0.0 0.0 0.0
0.0 2.0 0.0 0.0 0.0
julia> F = svdfact!(A);
julia> F = svd!(A);
julia> F.U * Diagonal(F.S) * F.Vt
4×5 Array{Float64,2}:
Expand All @@ -42,12 +42,12 @@ julia> A
0.0 0.0 -2.0 0.0 0.0
```
"""
function svdfact!(A::StridedMatrix{T}; full::Bool = false, thin::Union{Bool,Nothing} = nothing) where T<:BlasFloat
function svd!(A::StridedMatrix{T}; full::Bool = false, thin::Union{Bool,Nothing} = nothing) where T<:BlasFloat
# DEPRECATION TODO: remove deprecated thin argument and associated logic after 0.7
if thin != nothing
Base.depwarn(string("the `thin` keyword argument in `svdfact!(A; thin = $(thin))` has ",
Base.depwarn(string("the `thin` keyword argument in `svd!(A; thin = $(thin))` has ",
"been deprecated in favor of `full`, which has the opposite meaning, ",
"e.g. `svdfact!(A; full = $(!thin))`."), :svdfact!)
"e.g. `svd!(A; full = $(!thin))`."), :svd!)
full::Bool = !thin
end
m,n = size(A)
Expand Down Expand Up @@ -102,7 +102,7 @@ function svdfact(A::StridedVecOrMat{T}; full::Bool = false, thin::Union{Bool,Not
"e.g. `svdfact(A; full = $(!thin))`."), :svdfact)
full::Bool = !thin
end
svdfact!(copy_oftype(A, eigtype(T)), full = full)
svd!(copy_oftype(A, eigtype(T)), full = full)
end
function svdfact(x::Number; full::Bool = false, thin::Union{Bool,Nothing} = nothing)
# DEPRECATION TODO: remove deprecated thin argument and associated logic after 0.7
Expand Down Expand Up @@ -279,9 +279,9 @@ function GeneralizedSVD(U::AbstractMatrix{T}, V::AbstractMatrix{T}, Q::AbstractM
end

"""
svdfact!(A, B) -> GeneralizedSVD
svd!(A, B) -> GeneralizedSVD
`svdfact!` is the same as [`svdfact`](@ref), but modifies the arguments
`svd!` is the same as [`svdfact`](@ref), but modifies the arguments
`A` and `B` in-place, instead of making copies.
# Examples
Expand All @@ -296,7 +296,7 @@ julia> B = [0. 1.; 1. 0.]
0.0 1.0
1.0 0.0
julia> F = svdfact!(A, B);
julia> F = svd!(A, B);
julia> F.U*F.D1*F.R0*F.Q'
2×2 Array{Float64,2}:
Expand All @@ -319,7 +319,7 @@ julia> B
0.0 -1.0
```
"""
function svdfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasFloat
function svd!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasFloat
# xggsvd3 replaced xggsvd in LAPACK 3.6.0
if LAPACK.version() < v"3.6.0"
U, V, Q, a, b, k, l, R = LAPACK.ggsvd!('U', 'V', 'Q', A, B)
Expand All @@ -328,7 +328,7 @@ function svdfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasFloat
end
GeneralizedSVD(U, V, Q, a, b, Int(k), Int(l), R)
end
svdfact(A::StridedMatrix{T}, B::StridedMatrix{T}) where {T<:BlasFloat} = svdfact!(copy(A),copy(B))
svdfact(A::StridedMatrix{T}, B::StridedMatrix{T}) where {T<:BlasFloat} = svd!(copy(A),copy(B))

"""
svdfact(A, B) -> GeneralizedSVD
Expand Down Expand Up @@ -381,7 +381,7 @@ julia> F.V*F.D2*F.R0*F.Q'
"""
function svdfact(A::StridedMatrix{TA}, B::StridedMatrix{TB}) where {TA,TB}
S = promote_type(eigtype(TA),TB)
return svdfact!(copy_oftype(A, S), copy_oftype(B, S))
return svd!(copy_oftype(A, S), copy_oftype(B, S))
end
# This method can be heavily optimized but it is probably not critical
# and might introduce bugs or inconsistencies relative to the 1x1 matrix
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@ end
eigfact(A::AbstractTriangular) = Eigen(eigvals(A), eigvecs(A))

# Generic singular systems
for func in (:svd, :svdfact, :svdfact!, :svdvals)
for func in (:svd, :svdfact, :svd!, :svdvals)
@eval begin
($func)(A::AbstractTriangular) = ($func)(copyto!(similar(parent(A)), A))
end
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ srand(1)

@testset "Singular systems" begin
if (elty <: BlasReal)
@test AbstractArray(svdfact(T)) AbstractArray(svdfact!(copy(Tfull)))
@test AbstractArray(svdfact(T)) AbstractArray(svd!(copy(Tfull)))
@test svdvals(Tfull) svdvals(T)
u1, d1, v1 = svd(Tfull)
u2, d2, v2 = svd(T)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/test/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ a2img = randn(n,n)/2
@test usv\b a\b

if eltya <: BlasFloat
svdz = svdfact!(Matrix{eltya}(undef,0,0))
svdz = svd!(Matrix{eltya}(undef,0,0))
@test svdz.U Matrix{eltya}(I, 0, 0)
@test svdz.S real(zeros(eltya,0))
@test svdz.Vt Matrix{eltya}(I, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/test/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ for elty1 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFlo
if !(elty1 in (BigFloat, Complex{BigFloat})) # Not implemented yet
svd(A1)
svdfact(A1)
elty1 <: BlasFloat && svdfact!(copy(A1))
elty1 <: BlasFloat && svd!(copy(A1))
svdvals(A1)
end

Expand Down

0 comments on commit 1084fb4

Please sign in to comment.