diff --git a/NEWS.md b/NEWS.md index 899ce39c96cdd..8d71de839c96d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -453,6 +453,22 @@ Deprecated or removed * `logm` has been deprecated in favor of `log` ([#23505]). + * `full` has been deprecated in favor of more specific, better defined alternatives. + On structured matrices `A`, consider instead `Matrix(A)`, `Array(A)`, + `SparseMatrixCSC(A)`, or `sparse(A)`. On sparse arrays `S`, consider instead + `Vector(S)`, `Matrix(S)`, or `Array(S)` as appropriate. On factorizations `F`, + consider instead `Matrix(F)`, `Array(F)`, `AbstractMatrix(F)`, or `AbstractArray(F)`. + On implicit orthogonal factors `Q`, consider instead `Matrix(Q)` or `Array(Q)`; for + implicit orthogonal factors that can be recovered in square or truncated form, + see the deprecation message for square recovery instructions. On `Symmetric`, + `Hermitian`, or `AbstractTriangular` matrices `A`, consider instead `Matrix(S)`, + `Array(S)`, `SparseMatrixCSC(S)`, or `sparse(S)`. On `Symmetric` matrices `A` + particularly, consider instead `LinAlg.copytri!(copy(parent(A)), A.uplo)`. On + `Hermitian` matrices `A` particularly, consider instead + `LinAlg.copytri!(copy(parent(A)), A.uplo, true)`. On `UpperTriangular` matrices `A` + particularly, consider instead `triu!(copy(parent(A)))`. On `LowerTriangular` matrices + `A` particularly, consider instead `tril!(copy(parent(A)))` ([#24250]). + * Calling `union` with no arguments is deprecated; construct an empty set with an appropriate element type using `Set{T}()` instead ([#23144]). diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 3ffb9657e3e34..c4210f4c72ab9 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -855,13 +855,6 @@ Represents the array `y` as an array having the same indices type as `x`. of_indices(x, y) = similar(dims->y, oftype(indices(x), indices(y))) -""" - full(F) - -Reconstruct the matrix `A` from the factorization `F=factorize(A)`. -""" -full(x::AbstractArray) = x - ## range conversions ## map(::Type{T}, r::StepRange) where {T<:Real} = T(r.start):T(r.step):T(last(r)) diff --git a/base/deprecated.jl b/base/deprecated.jl index 325d367130bcc..6840c6f67b2a2 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1882,6 +1882,142 @@ end @deprecate diagm(v::AbstractVector, k::Integer) diagm(k => v) @deprecate diagm(x::Number) fill(x, 1, 1) +## deprecate full + +# full no-op fallback +function full(A::AbstractArray) + depwarn(string( + "The no-op `full(A::AbstractArray)` fallback has been deprecated, and no more ", + "specific `full` method for $(typeof(A)) exists. Furthermore, `full` in general ", + "has been deprecated.\n\n", + "To replace `full(A)`, as appropriate consider dismabiguating with a concrete ", + "array constructor (e.g. `Array(A)`), with an abstract array constructor (e.g.`AbstractArray(A)`), ", + "instead `convert`ing to an array type (e.g `convert(Array, A)`, `convert(AbstractArray, A)`), ", + "or using another such operation that addresses your specific use case."), :full) + return A +end + +# full for structured arrays +function full(A::Union{Diagonal,Bidiagonal,Tridiagonal,SymTridiagonal}) + mattypestr = isa(A, Diagonal) ? "Diagonal" : + isa(A, Bidiagonal) ? "Bidiagonal" : + isa(A, Tridiagonal) ? "Tridiagonal" : + isa(A, SymTridiagonal) ? "SymTridiagonal" : + error("should not be reachable!") + depwarn(string( + "`full(A::$(mattypestr))` (and `full` in general) has been deprecated. ", + "To replace `full(A::$(mattypestr))`, consider `Matrix(A)` or, if that ", + "option is too narrow, `Array(A)`. Also consider `SparseMatrixCSC(A)` ", + "or, if that option is too narrow, `sparse(A)`."), :full) + return Matrix(A) +end + +# full for sparse arrays +function full(S::Union{SparseVector,SparseMatrixCSC}) + (arrtypestr, desttypestr) = + isa(S, SparseVector) ? ("SparseVector", "Vector") : + isa(S, SparseMatrixCSC) ? ("SparseMatrixCSC", "Matrix") : + error("should not be reachable!") + depwarn(string( + "`full(S::$(arrtypestr))` (and `full` in general) has been deprecated. ", + "To replace `full(S::$(arrtypestr))`, consider `$(desttypestr)(S)` or, ", + "if that option is too narrow, `Array(S)`."), :full) + return Array(S) +end + +# full for factorizations +function full(F::Union{LinAlg.LU,LinAlg.LQ,LinAlg.QR,LinAlg.QRPivoted,LinAlg.QRCompactWY, + LinAlg.SVD,LinAlg.LDLt,LinAlg.Schur,LinAlg.Eigen,LinAlg.Hessenberg, + LinAlg.Cholesky,LinAlg.CholeskyPivoted}) + facttypestr = isa(F, LinAlg.LU) ? "LU" : + isa(F, LinAlg.LQ) ? "LQ" : + isa(F, LinAlg.QR) ? "QR" : + isa(F, LinAlg.QRPivoted) ? "QRPivoted" : + isa(F, LinAlg.QRCompactWY) ? "QRCompactWY" : + isa(F, LinAlg.SVD) ? "SVD" : + isa(F, LinAlg.LDLt) ? "LDLt" : + isa(F, LinAlg.Schur) ? "Schur" : + isa(F, LinAlg.Eigen) ? "Eigen" : + isa(F, LinAlg.Hessenberg) ? "Hessenberg" : + isa(F, LinAlg.Cholesky) ? "Cholesky" : + isa(F, LinAlg.CholeskyPivoted) ? "CholeskyPivoted" : + error("should not be reachable!") + depwarn(string( + "`full(F::$(facttypestr))` (and `full` in general) has been deprecated. ", + "To replace `full(F::$(facttypestr))`, consider `Matrix(F)`, `AbstractMatrix(F)` or, ", + "if those options are too narrow, `Array(F)` or `AbstractArray(F)`."), :full) + return AbstractMatrix(F) +end + +# full for implicit orthogonal factors +function full(Q::LinAlg.HessenbergQ) + depwarn(string( + "`full(Q::HessenbergQ)` (and `full` in general) has been deprecated. ", + "To replace `full(Q::HessenbergQ)`, consider `Matrix(Q)` or, ", + "if that option is too narrow, `Array(Q)`."), :full) + return Matrix(Q) +end +function full(Q::LinAlg.LQPackedQ; thin::Bool = true) + depwarn(string( + "`full(Q::LQPackedQ; thin::Bool = true)` (and `full` in general) ", + "has been deprecated. To replace `full(Q::LQPackedQ, true)`, ", + "consider `Matrix(Q)` or `Array(Q)`. To replace `full(Q::LQPackedQ, false)`, ", + "consider `Base.LinAlg.A_mul_B!(Q, eye(eltype(Q), size(Q.factors, 2)))`."), :full) + return thin ? Array(Q) : A_mul_B!(Q, eye(eltype(Q), size(Q.factors, 2))) +end +function full(Q::Union{LinAlg.QRPackedQ,LinAlg.QRCompactWYQ}; thin::Bool = true) + qtypestr = isa(Q, LinAlg.QRPackedQ) ? "QRPackedQ" : + isa(Q, LinAlg.QRCompactWYQ) ? "QRCompactWYQ" : + error("should not be reachable!") + depwarn(string( + "`full(Q::$(qtypestr); thin::Bool = true)` (and `full` in general) ", + "has been deprecated. To replace `full(Q::$(qtypestr), true)`, ", + "consider `Matrix(Q)` or `Array(Q)`. To replace `full(Q::$(qtypestr), false)`, ", + "consider `Base.LinAlg.A_mul_B!(Q, eye(eltype(Q), size(Q.factors, 1)))`."), :full) + return thin ? Array(Q) : A_mul_B!(Q, eye(eltype(Q), size(Q.factors, 1))) +end + +# full for symmetric / hermitian / triangular wrappers +function full(A::Symmetric) + depwarn(string( + "`full(A::Symmetric)` (and `full` in general) has been deprecated. ", + "To replace `full(A::Symmetric)`, as appropriate consider `Matrix(A)`, ", + "`Array(A)`, `SparseMatrixCSC(A)`, `sparse(A)`, `copy!(similar(parent(A)), A)`, ", + "or `Base.LinAlg.copytri!(copy(parent(A)), A.uplo)`."), :full) + return Matrix(A) +end +function full(A::Hermitian) + depwarn(string( + "`full(A::Hermitian)` (and `full` in general) has been deprecated. ", + "To replace `full(A::Hermitian)`, as appropriate consider `Matrix(A)`, ", + "`Array(A)`, `SparseMatrixCSC(A)`, `sparse(A)`, `copy!(similar(parent(A)), A)`, ", + "or `Base.LinAlg.copytri!(copy(parent(A)), A.uplo, true)`."), :full) + return Matrix(A) +end +function full(A::Union{UpperTriangular,LowerTriangular}) + (tritypestr, tri!str) = + isa(A, UpperTriangular) ? ("UpperTriangular", "triu!") : + isa(A, LowerTriangular) ? ("LowerTriangular", "tril!") : + error("should not be reachable!") + depwarn(string( + "`full(A::$(tritypestr))` (and `full` in general) has been deprecated. ", + "To replace `full(A::$(tritypestr))`, as appropriate consider `Matrix(A)`, ", + "`Array(A)`, `SparseMatrixCSC(A)`, `sparse(A)`, `copy!(similar(parent(A)), A)`, ", + "or `$(tri!str)(copy(parent(A)))`."), :full) + return Matrix(A) +end +function full(A::Union{LinAlg.UnitUpperTriangular,LinAlg.UnitLowerTriangular}) + tritypestr = isa(A, LinAlg.UnitUpperTriangular) ? "LinAlg.UnitUpperTriangular" : + isa(A, LinAlg.UnitLowerTriangular) ? "LinAlg.UnitLowerTriangular" : + error("should not be reachable!") + depwarn(string( + "`full(A::$(tritypestr))` (and `full` in general) has been deprecated. ", + "To replace `full(A::$(tritypestr))`, as appropriate consider `Matrix(A)`, ", + "`Array(A)`, `SparseMatrixCSC(A)`, `sparse(A)`, or `copy!(similar(parent(A)), A)`."), :full) + return Matrix(A) +end + + # issue #20816 @deprecate strwidth textwidth @deprecate charwidth textwidth diff --git a/base/exports.jl b/base/exports.jl index 09fd49d701fb2..108b04f165989 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -623,7 +623,6 @@ export ×, # sparse - full, dropzeros, dropzeros!, diff --git a/base/linalg/bidiag.jl b/base/linalg/bidiag.jl index 43f112a0e9411..f8d426b4857fd 100644 --- a/base/linalg/bidiag.jl +++ b/base/linalg/bidiag.jl @@ -147,7 +147,6 @@ function convert(::Type{Matrix{T}}, A::Bidiagonal) where T end convert(::Type{Matrix}, A::Bidiagonal{T}) where {T} = convert(Matrix{T}, A) convert(::Type{Array}, A::Bidiagonal) = convert(Matrix, A) -full(A::Bidiagonal) = convert(Array, A) promote_rule(::Type{Matrix{T}}, ::Type{<:Bidiagonal{S}}) where {T,S} = Matrix{promote_type(T,S)} #Converting from Bidiagonal to Tridiagonal diff --git a/base/linalg/cholesky.jl b/base/linalg/cholesky.jl index dfa9cfae217c7..5efb8bd0741e7 100644 --- a/base/linalg/cholesky.jl +++ b/base/linalg/cholesky.jl @@ -363,7 +363,6 @@ convert(::Type{AbstractMatrix}, C::Cholesky) = C.uplo == 'U' ? C[:U]'C[:U] : C[: convert(::Type{AbstractArray}, C::Cholesky) = convert(AbstractMatrix, C) convert(::Type{Matrix}, C::Cholesky) = convert(Array, convert(AbstractArray, C)) convert(::Type{Array}, C::Cholesky) = convert(Matrix, C) -full(C::Cholesky) = convert(AbstractArray, C) function convert(::Type{AbstractMatrix}, F::CholeskyPivoted) ip = invperm(F[:p]) @@ -372,7 +371,6 @@ end convert(::Type{AbstractArray}, F::CholeskyPivoted) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::CholeskyPivoted) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::CholeskyPivoted) = convert(Matrix, F) -full(F::CholeskyPivoted) = convert(AbstractArray, F) copy(C::Cholesky) = Cholesky(copy(C.factors), C.uplo, C.info) copy(C::CholeskyPivoted) = CholeskyPivoted(copy(C.factors), C.uplo, C.piv, C.rank, C.tol, C.info) diff --git a/base/linalg/diagonal.jl b/base/linalg/diagonal.jl index d0273215f8ffe..2953cd14dfa67 100644 --- a/base/linalg/diagonal.jl +++ b/base/linalg/diagonal.jl @@ -54,7 +54,6 @@ convert(::Type{Diagonal{T}}, D::Diagonal) where {T} = Diagonal{T}(convert(Abstra convert(::Type{AbstractMatrix{T}}, D::Diagonal) where {T} = convert(Diagonal{T}, D) convert(::Type{Matrix}, D::Diagonal) = diagm(0 => D.diag) convert(::Type{Array}, D::Diagonal) = convert(Matrix, D) -full(D::Diagonal) = convert(Array, D) # For D<:Diagonal, similar(D[, neweltype]) should yield a Diagonal matrix. # On the other hand, similar(D, [neweltype,] shape...) should yield a sparse matrix. diff --git a/base/linalg/eigen.jl b/base/linalg/eigen.jl index ad9158b8d70db..6c29e3a7736a8 100644 --- a/base/linalg/eigen.jl +++ b/base/linalg/eigen.jl @@ -435,4 +435,3 @@ convert(::Type{AbstractMatrix}, F::Eigen) = F.vectors * Diagonal(F.values) / F.v convert(::Type{AbstractArray}, F::Eigen) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::Eigen) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::Eigen) = convert(Matrix, F) -full(F::Eigen) = convert(AbstractArray, F) diff --git a/base/linalg/hessenberg.jl b/base/linalg/hessenberg.jl index ebb7e8ea0f665..fc4d44ddd9c3e 100644 --- a/base/linalg/hessenberg.jl +++ b/base/linalg/hessenberg.jl @@ -79,12 +79,10 @@ end ## reconstruct the original matrix convert(::Type{Matrix}, A::HessenbergQ{<:BlasFloat}) = LAPACK.orghr!(1, size(A.factors, 1), copy(A.factors), A.τ) convert(::Type{Array}, A::HessenbergQ) = convert(Matrix, A) -full(A::HessenbergQ) = convert(Array, A) convert(::Type{AbstractMatrix}, F::Hessenberg) = (fq = Array(F[:Q]); (fq * F[:H]) * fq') convert(::Type{AbstractArray}, F::Hessenberg) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::Hessenberg) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::Hessenberg) = convert(Matrix, F) -full(F::Hessenberg) = convert(AbstractArray, F) A_mul_B!(Q::HessenbergQ{T}, X::StridedVecOrMat{T}) where {T<:BlasFloat} = LAPACK.ormhr!('L', 'N', 1, size(Q.factors, 1), Q.factors, Q.τ, X) diff --git a/base/linalg/ldlt.jl b/base/linalg/ldlt.jl index 8f54e6e8d73f2..a2d65971ce78d 100644 --- a/base/linalg/ldlt.jl +++ b/base/linalg/ldlt.jl @@ -138,4 +138,3 @@ convert(::Type{AbstractMatrix}, F::LDLt) = convert(SymTridiagonal, F) convert(::Type{AbstractArray}, F::LDLt) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::LDLt) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::LDLt) = convert(Matrix, F) -full(F::LDLt) = convert(AbstractArray, F) diff --git a/base/linalg/linalg.jl b/base/linalg/linalg.jl index 68d341478db8a..410d81e14a8b4 100644 --- a/base/linalg/linalg.jl +++ b/base/linalg/linalg.jl @@ -12,7 +12,7 @@ import Base: A_mul_Bt, At_ldiv_Bt, A_rdiv_Bc, At_ldiv_B, Ac_mul_Bc, A_mul_Bc, Ac Ac_ldiv_B, Ac_ldiv_Bc, At_mul_Bt, A_rdiv_Bt, At_mul_B import Base: USE_BLAS64, abs, acos, acosh, acot, acoth, acsc, acsch, adjoint, asec, asech, asin, asinh, atan, atanh, big, broadcast, ceil, conj, convert, copy, copy!, cos, cosh, cot, coth, csc, - csch, eltype, exp, eye, findmax, findmin, fill!, floor, full, getindex, hcat, imag, indices, + csch, eltype, exp, eye, findmax, findmin, fill!, floor, getindex, hcat, imag, indices, inv, isapprox, isone, IndexStyle, kron, length, log, map, ndims, oneunit, parent, power_by_squaring, print_matrix, promote_rule, real, round, sec, sech, setindex!, show, similar, sin, sincos, sinh, size, sqrt, tan, tanh, transpose, trunc, typed_hcat, vec diff --git a/base/linalg/lq.jl b/base/linalg/lq.jl index 356b3e99b9228..66dcff8ebf770 100644 --- a/base/linalg/lq.jl +++ b/base/linalg/lq.jl @@ -62,7 +62,6 @@ convert(::Type{AbstractMatrix}, A::LQ) = A[:L]*A[:Q] convert(::Type{AbstractArray}, A::LQ) = convert(AbstractMatrix, A) convert(::Type{Matrix}, A::LQ) = convert(Array, convert(AbstractArray, A)) convert(::Type{Array}, A::LQ) = convert(Matrix, A) -full(A::LQ) = convert(AbstractArray, A) adjoint(A::LQ{T}) where {T} = QR{T,typeof(A.factors)}(A.factors', A.τ) @@ -94,9 +93,6 @@ convert(::Type{AbstractMatrix{T}}, Q::LQPackedQ) where {T} = convert(LQPackedQ{T convert(::Type{Matrix}, A::LQPackedQ) = LAPACK.orglq!(copy(A.factors),A.τ) convert(::Type{Array}, A::LQPackedQ) = convert(Matrix, A) -full(Q::LQPackedQ; thin::Bool = true) = - thin ? Array(Q) : A_mul_B!(Q, eye(eltype(Q), size(Q.factors, 2))) - size(A::LQ, dim::Integer) = size(A.factors, dim) size(A::LQ) = size(A.factors) diff --git a/base/linalg/lu.jl b/base/linalg/lu.jl index 9bae05f033af9..b409fe12ae50d 100644 --- a/base/linalg/lu.jl +++ b/base/linalg/lu.jl @@ -550,7 +550,6 @@ convert(::Type{AbstractMatrix}, F::LU) = (F[:L] * F[:U])[invperm(F[:p]),:] convert(::Type{AbstractArray}, F::LU) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::LU) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::LU) = convert(Matrix, F) -full(F::LU) = convert(AbstractArray, F) function convert(::Type{Tridiagonal}, F::Base.LinAlg.LU{T,Tridiagonal{T,V}}) where {T,V} n = size(F, 1) @@ -594,4 +593,3 @@ convert(::Type{Matrix}, F::LU{T,Tridiagonal{T,V}}) where {T,V} = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::LU{T,Tridiagonal{T,V}}) where {T,V} = convert(Matrix, F) -full(F::LU{T,Tridiagonal{T,V}}) where {T,V} = convert(AbstractArray, F) diff --git a/base/linalg/qr.jl b/base/linalg/qr.jl index 708dfeb192949..b83cb0351261a 100644 --- a/base/linalg/qr.jl +++ b/base/linalg/qr.jl @@ -267,7 +267,7 @@ solution and if the solution is not unique, the one with smallest norm is return Multiplication with respect to either thin or full `Q` is allowed, i.e. both `F[:Q]*F[:R]` and `F[:Q]*A` are supported. A `Q` matrix can be converted into a regular matrix with -[`full`](@ref) which has a named argument `thin`. +[`Matrix`](@ref). # Examples ```jldoctest @@ -401,7 +401,6 @@ convert(::Type{AbstractMatrix}, F::Union{QR,QRCompactWY}) = F[:Q] * F[:R] convert(::Type{AbstractArray}, F::Union{QR,QRCompactWY}) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::Union{QR,QRCompactWY}) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::Union{QR,QRCompactWY}) = convert(Matrix, F) -full(F::Union{QR,QRCompactWY}) = convert(AbstractArray, F) convert(::Type{QRPivoted{T}}, A::QRPivoted) where {T} = QRPivoted(convert(AbstractMatrix{T}, A.factors), convert(Vector{T}, A.τ), A.jpvt) convert(::Type{Factorization{T}}, A::QRPivoted{T}) where {T} = A convert(::Type{Factorization{T}}, A::QRPivoted) where {T} = convert(QRPivoted{T}, A) @@ -409,7 +408,6 @@ convert(::Type{AbstractMatrix}, F::QRPivoted) = (F[:Q] * F[:R])[:,invperm(F[:p]) convert(::Type{AbstractArray}, F::QRPivoted) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::QRPivoted) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::QRPivoted) = convert(Matrix, F) -full(F::QRPivoted) = convert(AbstractArray, F) function show(io::IO, F::Union{QR, QRCompactWY, QRPivoted}) println(io, "$(typeof(F)) with factors Q and R:") @@ -500,58 +498,6 @@ convert(::Type{AbstractMatrix{S}}, Q::QRCompactWYQ) where {S} = convert(QRCompac convert(::Type{Matrix}, A::AbstractQ{T}) where {T} = A_mul_B!(A, eye(T, size(A.factors, 1), min(size(A.factors)...))) convert(::Type{Array}, A::AbstractQ) = convert(Matrix, A) -""" - full(A::AbstractQ; thin::Bool=true) -> Matrix - -Converts an orthogonal or unitary matrix stored as a `QRCompactWYQ` object, i.e. in the -compact WY format [^Bischof1987], or in the `QRPackedQ` format, to a dense matrix. - -Optionally takes a `thin` Boolean argument, which if `true` omits the columns that span the -rows of `R` in the QR factorization that are zero. The resulting matrix is the `Q` in a thin -QR factorization (sometimes called the reduced QR factorization). If `false`, returns a `Q` -that spans all rows of `R` in its corresponding QR factorization. - -# Examples -```jldoctest -julia> a = [1. 2.; 3. 4.; 5. 6.]; - -julia> qra = qrfact(a, Val(true)); - -julia> full(qra[:Q], thin=true) -3×2 Array{Float64,2}: - -0.267261 0.872872 - -0.534522 0.218218 - -0.801784 -0.436436 - -julia> full(qra[:Q], thin=false) -3×3 Array{Float64,2}: - -0.267261 0.872872 0.408248 - -0.534522 0.218218 -0.816497 - -0.801784 -0.436436 0.408248 - -julia> qra = qrfact(a, Val(false)); - -julia> full(qra[:Q], thin=true) -3×2 Array{Float64,2}: - -0.169031 0.897085 - -0.507093 0.276026 - -0.845154 -0.345033 - -julia> full(qra[:Q], thin=false) -3×3 Array{Float64,2}: - -0.169031 0.897085 0.408248 - -0.507093 0.276026 -0.816497 - -0.845154 -0.345033 0.408248 -``` -""" -function full(A::AbstractQ{T}; thin::Bool = true) where T - if thin - convert(Array, A) - else - A_mul_B!(A, eye(T, size(A.factors, 1))) - end -end - size(A::Union{QR,QRCompactWY,QRPivoted}, dim::Integer) = size(A.factors, dim) size(A::Union{QR,QRCompactWY,QRPivoted}) = size(A.factors) size(A::AbstractQ, dim::Integer) = 0 < dim ? (dim <= 2 ? size(A.factors, 1) : 1) : throw(BoundsError()) diff --git a/base/linalg/schur.jl b/base/linalg/schur.jl index 800e08e054f87..f3b47900f3b70 100644 --- a/base/linalg/schur.jl +++ b/base/linalg/schur.jl @@ -282,7 +282,6 @@ convert(::Type{AbstractMatrix}, F::Schur) = (F.Z * F.T) * F.Z' convert(::Type{AbstractArray}, F::Schur) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::Schur) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::Schur) = convert(Matrix, F) -full(F::Schur) = convert(AbstractArray, F) copy(F::Schur) = Schur(copy(F.T), copy(F.Z), copy(F.values)) copy(F::GeneralizedSchur) = GeneralizedSchur(copy(F.S), copy(F.T), copy(F.alpha), copy(F.beta), copy(F.Q), copy(F.Z)) diff --git a/base/linalg/svd.jl b/base/linalg/svd.jl index a4b3106850217..6b4ace6cce2d3 100644 --- a/base/linalg/svd.jl +++ b/base/linalg/svd.jl @@ -314,4 +314,3 @@ convert(::Type{AbstractMatrix}, F::SVD) = (F.U * Diagonal(F.S)) * F.Vt convert(::Type{AbstractArray}, F::SVD) = convert(AbstractMatrix, F) convert(::Type{Matrix}, F::SVD) = convert(Array, convert(AbstractArray, F)) convert(::Type{Array}, F::SVD) = convert(Matrix, F) -full(F::SVD) = convert(AbstractArray, F) diff --git a/base/linalg/symmetric.jl b/base/linalg/symmetric.jl index 381181774fd40..f9f16d8ef7307 100644 --- a/base/linalg/symmetric.jl +++ b/base/linalg/symmetric.jl @@ -155,7 +155,6 @@ similar(A::Union{Symmetric,Hermitian}, ::Type{T}, dims::Dims{N}) where {T,N} = s convert(::Type{Matrix}, A::Symmetric) = copytri!(convert(Matrix, copy(A.data)), A.uplo) convert(::Type{Matrix}, A::Hermitian) = copytri!(convert(Matrix, copy(A.data)), A.uplo, true) convert(::Type{Array}, A::Union{Symmetric,Hermitian}) = convert(Matrix, A) -full(A::Union{Symmetric,Hermitian}) = convert(Array, A) parent(A::HermOrSym) = A.data convert(::Type{Symmetric{T,S}},A::Symmetric{T,S}) where {T,S<:AbstractMatrix} = A convert(::Type{Symmetric{T,S}},A::Symmetric) where {T,S<:AbstractMatrix} = Symmetric{T,S}(convert(S,A.data),A.uplo) diff --git a/base/linalg/triangular.jl b/base/linalg/triangular.jl index fa7d325d5d3c7..8f568681cf49c 100644 --- a/base/linalg/triangular.jl +++ b/base/linalg/triangular.jl @@ -101,7 +101,6 @@ imag(A::UnitLowerTriangular) = LowerTriangular(tril!(imag(A.data),-1)) imag(A::UnitUpperTriangular) = UpperTriangular(triu!(imag(A.data),1)) convert(::Type{Array}, A::AbstractTriangular) = convert(Matrix, A) -full(A::AbstractTriangular) = convert(Array, A) parent(A::AbstractTriangular) = A.data # then handle all methods that requires specific handling of upper/lower and unit diagonal diff --git a/base/linalg/tridiag.jl b/base/linalg/tridiag.jl index f6f71b0f71b40..32596a9713a9e 100644 --- a/base/linalg/tridiag.jl +++ b/base/linalg/tridiag.jl @@ -95,7 +95,6 @@ function convert(::Type{Matrix{T}}, M::SymTridiagonal) where T end convert(::Type{Matrix}, M::SymTridiagonal{T}) where {T} = convert(Matrix{T}, M) convert(::Type{Array}, M::SymTridiagonal) = convert(Matrix, M) -full(M::SymTridiagonal) = convert(Array, M) size(A::SymTridiagonal) = (length(A.dv), length(A.dv)) function size(A::SymTridiagonal, d::Integer) @@ -502,7 +501,6 @@ function convert(::Type{Matrix{T}}, M::Tridiagonal{T}) where T end convert(::Type{Matrix}, M::Tridiagonal{T}) where {T} = convert(Matrix{T}, M) convert(::Type{Array}, M::Tridiagonal) = convert(Matrix, M) -full(M::Tridiagonal) = convert(Array, M) # For M<:Tridiagonal, similar(M[, neweltype]) should yield a Tridiagonal matrix. # On the other hand, similar(M, [neweltype,] shape...) should yield a sparse matrix. diff --git a/base/sparse/sparse.jl b/base/sparse/sparse.jl index e1ef23c364c91..4bffa183a8fbb 100644 --- a/base/sparse/sparse.jl +++ b/base/sparse/sparse.jl @@ -23,7 +23,7 @@ import Base: @get!, acos, acosd, acot, acotd, acsch, asech, asin, asind, asinh, sinc, sind, sinh, sinpi, squeeze, start, sum, summary, tan, tand, tanh, trace, transpose!, tril!, triu!, trunc, vecnorm, abs, abs2, broadcast, ceil, complex, cond, conj, convert, copy, copy!, adjoint, diagm, - exp, expm1, factorize, find, findmax, findmin, findnz, float, full, getindex, + exp, expm1, factorize, find, findmax, findmin, findnz, float, getindex, vcat, hcat, hvcat, cat, imag, indmax, ishermitian, kron, length, log, log1p, max, min, maximum, minimum, norm, one, promote_eltype, real, reshape, rot180, rotl90, rotr90, round, scale!, setindex!, similar, size, transpose, tril, diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index be2845048e2ab..beb060915f549 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -386,32 +386,8 @@ function convert(::Type{Matrix}, S::SparseMatrixCSC{Tv}) where Tv return A end convert(::Type{Array}, S::SparseMatrixCSC) = convert(Matrix, S) -full(S::SparseMatrixCSC) = convert(Array, S) - -""" - full(S) - -Convert a sparse matrix or vector `S` into a dense matrix or vector. - -# Examples -```jldoctest -julia> A = speye(3) -3×3 SparseMatrixCSC{Float64,Int64} with 3 stored entries: - [1, 1] = 1.0 - [2, 2] = 1.0 - [3, 3] = 1.0 - -julia> full(A) -3×3 Array{Float64,2}: - 1.0 0.0 0.0 - 0.0 1.0 0.0 - 0.0 0.0 1.0 -``` -""" -full float(S::SparseMatrixCSC) = SparseMatrixCSC(S.m, S.n, copy(S.colptr), copy(S.rowval), float.(S.nzval)) - complex(S::SparseMatrixCSC) = SparseMatrixCSC(S.m, S.n, copy(S.colptr), copy(S.rowval), complex(copy(S.nzval))) # Construct a sparse vector diff --git a/base/sparse/sparsevector.jl b/base/sparse/sparsevector.jl index ddaf2ef9ebf54..86e3a05cde85a 100644 --- a/base/sparse/sparsevector.jl +++ b/base/sparse/sparsevector.jl @@ -848,7 +848,6 @@ function convert(::Type{Vector}, x::AbstractSparseVector{Tv}) where Tv return r end convert(::Type{Array}, x::AbstractSparseVector) = convert(Vector, x) -full(x::AbstractSparseVector) = convert(Array, x) ### Array manipulation diff --git a/doc/src/manual/arrays.md b/doc/src/manual/arrays.md index ad9e859dd4b16..0bc4a53a53f8f 100644 --- a/doc/src/manual/arrays.md +++ b/doc/src/manual/arrays.md @@ -896,7 +896,7 @@ section of the standard library reference. | [`spzeros(m,n)`](@ref) | [`zeros(m,n)`](@ref) | Creates a *m*-by-*n* matrix of zeros. ([`spzeros(m,n)`](@ref) is empty.) | | [`spones(S)`](@ref) | [`ones(m,n)`](@ref) | Creates a matrix filled with ones. Unlike the dense version, [`spones`](@ref) has the same sparsity pattern as *S*. | | [`speye(n)`](@ref) | [`eye(n)`](@ref) | Creates a *n*-by-*n* identity matrix. | -| [`full(S)`](@ref) | [`sparse(A)`](@ref) | Interconverts between dense and sparse formats. | +| [`Array(S)`](@ref) | [`sparse(A)`](@ref) | Interconverts between dense and sparse formats. | | [`sprand(m,n,d)`](@ref) | [`rand(m,n)`](@ref) | Creates a *m*-by-*n* random matrix (of density *d*) with iid non-zero elements distributed uniformly on the half-open interval ``[0, 1)``. | | [`sprandn(m,n,d)`](@ref) | [`randn(m,n)`](@ref) | Creates a *m*-by-*n* random matrix (of density *d*) with iid non-zero elements distributed according to the standard normal (Gaussian) distribution. | | [`sprandn(m,n,d,X)`](@ref) | [`randn(m,n,X)`](@ref) | Creates a *m*-by-*n* random matrix (of density *d*) with iid non-zero elements distributed according to the *X* distribution. (Requires the `Distributions` package.) | diff --git a/doc/src/stdlib/arrays.md b/doc/src/stdlib/arrays.md index 86bcddb6fa1d1..0073510805c5f 100644 --- a/doc/src/stdlib/arrays.md +++ b/doc/src/stdlib/arrays.md @@ -185,7 +185,6 @@ Base.SparseArrays.SparseMatrixCSC Base.SparseArrays.sparse Base.SparseArrays.sparsevec Base.SparseArrays.issparse -Base.full Base.SparseArrays.nnz Base.SparseArrays.spzeros Base.SparseArrays.spones