diff --git a/base/linalg/bidiag.jl b/base/linalg/bidiag.jl index 15913677df72a..1eaff9c3ff533 100644 --- a/base/linalg/bidiag.jl +++ b/base/linalg/bidiag.jl @@ -18,7 +18,7 @@ end Constructs an upper (`isupper=true`) or lower (`isupper=false`) bidiagonal matrix using the given diagonal (`dv`) and off-diagonal (`ev`) vectors. The result is of type `Bidiagonal` and provides efficient specialized linear solvers, but may be converted into a regular -matrix with [`full`](:func:`full`). `ev`'s length must be one less than the length of `dv`. +matrix with [`convert(Array, _)`](:func:`convert`). `ev`'s length must be one less than the length of `dv`. **Example** @@ -38,7 +38,7 @@ Bidiagonal(dv::AbstractVector, ev::AbstractVector) = throw(ArgumentError("did yo Constructs an upper (`uplo='U'`) or lower (`uplo='L'`) bidiagonal matrix using the given diagonal (`dv`) and off-diagonal (`ev`) vectors. The result is of type `Bidiagonal` and provides efficient specialized linear solvers, but may be converted into a regular -matrix with [`full`](:func:`full`). `ev`'s length must be one less than the length of `dv`. +matrix with [`convert(Array, _)`](:func:`convert`). `ev`'s length must be one less than the length of `dv`. **Example** @@ -302,7 +302,7 @@ end function A_mul_B_td!(C::AbstractMatrix, A::BiTriSym, B::BiTriSym) check_A_mul_B!_sizes(C, A, B) n = size(A,1) - n <= 3 && return A_mul_B!(C, full(A), full(B)) + n <= 3 && return A_mul_B!(C, convert(Array, A), convert(Array, B)) fill!(C, zero(eltype(C))) Al = diag(A, -1) Ad = diag(A, 0) @@ -361,7 +361,7 @@ function A_mul_B_td!(C::AbstractVecOrMat, A::BiTriSym, B::AbstractVecOrMat) if size(C,2) != nB throw(DimensionMismatch("A has second dimension $nA, B has $(size(B,2)), C has $(size(C,2)) but all must match")) end - nA <= 3 && return A_mul_B!(C, full(A), full(B)) + nA <= 3 && return A_mul_B!(C, convert(Array, A), convert(Array, B)) l = diag(A, -1) d = diag(A, 0) u = diag(A, 1) @@ -382,7 +382,7 @@ end function A_mul_B_td!(C::AbstractMatrix, A::AbstractMatrix, B::BiTriSym) check_A_mul_B!_sizes(C, A, B) n = size(A,1) - n <= 3 && return A_mul_B!(C, full(A), full(B)) + n <= 3 && return A_mul_B!(C, convert(Array, A), convert(Array, B)) m = size(B,2) Bl = diag(B, -1) Bd = diag(B, 0) @@ -412,12 +412,12 @@ end SpecialMatrix = Union{Bidiagonal, SymTridiagonal, Tridiagonal} # to avoid ambiguity warning, but shouldn't be necessary -*(A::AbstractTriangular, B::SpecialMatrix) = full(A) * full(B) -*(A::SpecialMatrix, B::SpecialMatrix) = full(A) * full(B) +*(A::AbstractTriangular, B::SpecialMatrix) = convert(Array, A) * convert(Array, B) +*(A::SpecialMatrix, B::SpecialMatrix) = convert(Array, A) * convert(Array, B) #Generic multiplication for func in (:*, :Ac_mul_B, :A_mul_Bc, :/, :A_rdiv_Bc) - @eval ($func){T}(A::Bidiagonal{T}, B::AbstractVector{T}) = ($func)(full(A), B) + @eval ($func){T}(A::Bidiagonal{T}, B::AbstractVector{T}) = ($func)(convert(Array, A), B) end #Linear solvers diff --git a/base/linalg/dense.jl b/base/linalg/dense.jl index b0fbe81de720a..d8518a7c5b0ef 100644 --- a/base/linalg/dense.jl +++ b/base/linalg/dense.jl @@ -173,7 +173,7 @@ expm(x::Number) = exp(x) function expm!{T<:BlasFloat}(A::StridedMatrix{T}) n = checksquare(A) if ishermitian(A) - return full(expm(Hermitian(A))) + return convert(Array, expm(Hermitian(A))) end ilo, ihi, scale = LAPACK.gebal!('B', A) # modifies A nA = norm(A, 1) @@ -285,13 +285,13 @@ triangular factor. function logm(A::StridedMatrix) # If possible, use diagonalization if ishermitian(A) - return full(logm(Hermitian(A))) + return convert(Array, logm(Hermitian(A))) end # Use Schur decomposition n = checksquare(A) if istriu(A) - retmat = full(logm(UpperTriangular(complex(A)))) + retmat = convert(Array, logm(UpperTriangular(complex(A)))) d = diag(A) else S,Q,d = schur(complex(A)) @@ -322,27 +322,27 @@ logm(a::Complex) = log(a) function sqrtm{T<:Real}(A::StridedMatrix{T}) if issymmetric(A) - return full(sqrtm(Symmetric(A))) + return convert(Array, sqrtm(Symmetric(A))) end n = checksquare(A) if istriu(A) - return full(sqrtm(UpperTriangular(A))) + return convert(Array, sqrtm(UpperTriangular(A))) else SchurF = schurfact(complex(A)) - R = full(sqrtm(UpperTriangular(SchurF[:T]))) + R = convert(Array, sqrtm(UpperTriangular(SchurF[:T]))) return SchurF[:vectors] * R * SchurF[:vectors]' end end function sqrtm{T<:Complex}(A::StridedMatrix{T}) if ishermitian(A) - return full(sqrtm(Hermitian(A))) + return convert(Array, sqrtm(Hermitian(A))) end n = checksquare(A) if istriu(A) - return full(sqrtm(UpperTriangular(A))) + return convert(Array, sqrtm(UpperTriangular(A))) else SchurF = schurfact(A) - R = full(sqrtm(UpperTriangular(SchurF[:T]))) + R = convert(Array, sqrtm(UpperTriangular(SchurF[:T]))) return SchurF[:vectors] * R * SchurF[:vectors]' end end diff --git a/base/linalg/diagonal.jl b/base/linalg/diagonal.jl index aff8735e4c7ca..e0369ff642c21 100644 --- a/base/linalg/diagonal.jl +++ b/base/linalg/diagonal.jl @@ -310,7 +310,7 @@ svdvals(D::Diagonal) = [svdvals(v) for v in D.diag] function svd{T<:Number}(D::Diagonal{T}) S = abs(D.diag) piv = sortperm(S, rev = true) - U = full(Diagonal(D.diag ./ S)) + U = convert(Array, Diagonal(D.diag ./ S)) Up = hcat([U[:,i] for i = 1:length(D.diag)][piv]...) V = eye(D) Vp = hcat([V[:,i] for i = 1:length(D.diag)][piv]...) diff --git a/base/linalg/hessenberg.jl b/base/linalg/hessenberg.jl index 83088cda465eb..2b9f2466b7984 100644 --- a/base/linalg/hessenberg.jl +++ b/base/linalg/hessenberg.jl @@ -23,7 +23,7 @@ end Compute the Hessenberg decomposition of `A` and return a `Hessenberg` object. If `F` is the factorization object, the unitary matrix can be accessed with `F[:Q]` and the Hessenberg matrix with `F[:H]`. When `Q` is extracted, the resulting type is the `HessenbergQ` object, -and may be converted to a regular matrix with [`full`](:func:`full`). +and may be converted to a regular matrix with [`convert(Array, _)`](:func:`convert`). """ hessfact @@ -56,7 +56,7 @@ end convert{T<:BlasFloat}(::Type{Matrix}, A::HessenbergQ{T}) = 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 = full(F[:Q]); (fq * F[:H]) * fq') +convert(::Type{AbstractMatrix}, F::Hessenberg) = (fq = convert(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) diff --git a/base/linalg/lq.jl b/base/linalg/lq.jl index cb10bb81bac5d..a0806370b1f1b 100644 --- a/base/linalg/lq.jl +++ b/base/linalg/lq.jl @@ -42,8 +42,9 @@ zeros if the full `Q` is requested. """ function lq(A::Union{Number, AbstractMatrix}; thin::Bool=true) F = lqfact(A) - F[:L], full(F[:Q], thin=thin) + F[:L], thin ? convert(Array, F[:Q]) : thickQ(F[:Q]) end +thickQ{T}(Q::LQPackedQ{T}) = A_mul_B!(Q, eye(T, size(Q.factors,2), size(Q.factors,1))) copy(A::LQ) = LQ(copy(A.factors), copy(A.τ)) @@ -112,8 +113,8 @@ size(A::LQPackedQ) = size(A.factors) ## Multiplication by LQ A_mul_B!{T<:BlasFloat}(A::LQ{T}, B::StridedVecOrMat{T}) = A[:L]*LAPACK.ormlq!('L','N',A.factors,A.τ,B) -A_mul_B!{T<:BlasFloat}(A::LQ{T}, B::QR{T}) = A[:L]*LAPACK.ormlq!('L','N',A.factors,A.τ,full(B)) -A_mul_B!{T<:BlasFloat}(A::QR{T}, B::LQ{T}) = A_mul_B!(zeros(full(A)), full(A), full(B)) +A_mul_B!{T<:BlasFloat}(A::LQ{T}, B::QR{T}) = A[:L]*LAPACK.ormlq!('L','N',A.factors,A.τ,convert(Array, B)) +A_mul_B!{T<:BlasFloat}(A::QR{T}, B::LQ{T}) = A_mul_B!(zeros(convert(Array, A)), convert(Array, A), convert(Array, B)) function *{TA,TB}(A::LQ{TA},B::StridedVecOrMat{TB}) TAB = promote_type(TA, TB) A_mul_B!(convert(Factorization{TAB},A), copy_oftype(B, TAB)) diff --git a/base/linalg/lu.jl b/base/linalg/lu.jl index 5201decd46fc6..49ebea091c2f8 100644 --- a/base/linalg/lu.jl +++ b/base/linalg/lu.jl @@ -308,7 +308,7 @@ factorize(A::Tridiagonal) = lufact(A) function getindex{T}(F::Base.LinAlg.LU{T,Tridiagonal{T}}, d::Symbol) m, n = size(F) if d == :L - L = full(Bidiagonal(ones(T, n), F.factors.dl, false)) + L = convert(Array, Bidiagonal(ones(T, n), F.factors.dl, false)) for i = 2:n tmp = L[F.ipiv[i], 1:i - 1] L[F.ipiv[i], 1:i - 1] = L[i, 1:i - 1] @@ -316,7 +316,7 @@ function getindex{T}(F::Base.LinAlg.LU{T,Tridiagonal{T}}, d::Symbol) end return L elseif d == :U - U = full(Bidiagonal(F.factors.d, F.factors.du, true)) + U = convert(Array, Bidiagonal(F.factors.d, F.factors.du, true)) for i = 1:n - 2 U[i,i + 2] = F.factors.du2[i] end diff --git a/base/linalg/qr.jl b/base/linalg/qr.jl index ba1797bc6105e..82009e25252c2 100644 --- a/base/linalg/qr.jl +++ b/base/linalg/qr.jl @@ -174,13 +174,14 @@ qr(A::Union{Number, AbstractMatrix}, pivot::Union{Type{Val{false}}, Type{Val{tru _qr(A, pivot, thin=thin) function _qr(A::Union{Number, AbstractMatrix}, ::Type{Val{false}}; thin::Bool=true) F = qrfact(A, Val{false}) - full(getq(F), thin=thin), F[:R]::Matrix{eltype(F)} + (thin ? convert(Array, getq(F)) : thickQ(getq(F))), F[:R]::Matrix{eltype(F)} end function _qr(A::Union{Number, AbstractMatrix}, ::Type{Val{true}}; thin::Bool=true) F = qrfact(A, Val{true}) - full(getq(F), thin=thin), F[:R]::Matrix{eltype(F)}, F[:p]::Vector{BlasInt} + (thin ? convert(Array, getq(F)) : thickQ(getq(F))), F[:R]::Matrix{eltype(F)}, F[:p]::Vector{BlasInt} end + """ qr(v::AbstractVector) @@ -325,6 +326,8 @@ function full{T}(A::Union{QRPackedQ{T},QRCompactWYQ{T}}; thin::Bool = true) end end +thickQ{T}(Q::Union{QRPackedQ{T},QRCompactWYQ{T}}) = A_mul_B!(Q, eye(T, size(Q.factors, 1))) + size(A::Union{QR,QRCompactWY,QRPivoted}, dim::Integer) = size(A.factors, dim) size(A::Union{QR,QRCompactWY,QRPivoted}) = size(A.factors) size(A::Union{QRPackedQ,QRCompactWYQ}, dim::Integer) = 0 < dim ? (dim <= 2 ? size(A.factors, 1) : 1) : throw(BoundsError()) diff --git a/base/linalg/special.jl b/base/linalg/special.jl index f70d67130807b..c8d86d559b689 100644 --- a/base/linalg/special.jl +++ b/base/linalg/special.jl @@ -6,21 +6,21 @@ convert{T}(::Type{Bidiagonal}, A::Diagonal{T})=Bidiagonal(A.diag, zeros(T, size(A.diag,1)-1), true) convert{T}(::Type{SymTridiagonal}, A::Diagonal{T})=SymTridiagonal(A.diag, zeros(T, size(A.diag,1)-1)) convert{T}(::Type{Tridiagonal}, A::Diagonal{T})=Tridiagonal(zeros(T, size(A.diag,1)-1), A.diag, zeros(T, size(A.diag,1)-1)) -convert(::Type{LowerTriangular}, A::Bidiagonal) = !A.isupper ? LowerTriangular(full(A)) : throw(ArgumentError("Bidiagonal matrix must have lower off diagonal to be converted to LowerTriangular")) -convert(::Type{UpperTriangular}, A::Bidiagonal) = A.isupper ? UpperTriangular(full(A)) : throw(ArgumentError("Bidiagonal matrix must have upper off diagonal to be converted to UpperTriangular")) +convert(::Type{LowerTriangular}, A::Bidiagonal) = !A.isupper ? LowerTriangular(convert(Array, A)) : throw(ArgumentError("Bidiagonal matrix must have lower off diagonal to be converted to LowerTriangular")) +convert(::Type{UpperTriangular}, A::Bidiagonal) = A.isupper ? UpperTriangular(convert(Array, A)) : throw(ArgumentError("Bidiagonal matrix must have upper off diagonal to be converted to UpperTriangular")) function convert(::Type{UnitUpperTriangular}, A::Diagonal) if !all(A.diag .== one(eltype(A))) throw(ArgumentError("matrix cannot be represented as UnitUpperTriangular")) end - UnitUpperTriangular(full(A)) + UnitUpperTriangular(convert(Array, A)) end function convert(::Type{UnitLowerTriangular}, A::Diagonal) if !all(A.diag .== one(eltype(A))) throw(ArgumentError("matrix cannot be represented as UnitLowerTriangular")) end - UnitLowerTriangular(full(A)) + UnitLowerTriangular(convert(Array, A)) end function convert(::Type{Diagonal}, A::Union{Bidiagonal, SymTridiagonal}) @@ -72,14 +72,14 @@ function convert(::Type{Tridiagonal}, A::SymTridiagonal) end function convert(::Type{Diagonal}, A::AbstractTriangular) - if full(A) != diagm(diag(A)) + if convert(Array, A) != diagm(diag(A)) throw(ArgumentError("matrix cannot be represented as Diagonal")) end Diagonal(diag(A)) end function convert(::Type{Bidiagonal}, A::AbstractTriangular) - fA = full(A) + fA = convert(Array, A) if fA == diagm(diag(A)) + diagm(diag(fA, 1), 1) return Bidiagonal(diag(A), diag(fA,1), true) elseif fA == diagm(diag(A)) + diagm(diag(fA, -1), -1) @@ -92,7 +92,7 @@ end convert(::Type{SymTridiagonal}, A::AbstractTriangular) = convert(SymTridiagonal, convert(Tridiagonal, A)) function convert(::Type{Tridiagonal}, A::AbstractTriangular) - fA = full(A) + fA = convert(Array, A) if fA == diagm(diag(A)) + diagm(diag(fA, 1), 1) + diagm(diag(fA, -1), -1) return Tridiagonal(diag(fA, -1), diag(A), diag(fA,1)) else @@ -154,12 +154,12 @@ for op in (:+, :-) end for matrixtype in (:SymTridiagonal,:Tridiagonal,:Bidiagonal,:Matrix) @eval begin - ($op)(A::AbstractTriangular, B::($matrixtype)) = ($op)(full(A), B) - ($op)(A::($matrixtype), B::AbstractTriangular) = ($op)(A, full(B)) + ($op)(A::AbstractTriangular, B::($matrixtype)) = ($op)(convert(Array, A), B) + ($op)(A::($matrixtype), B::AbstractTriangular) = ($op)(A, convert(Array, B)) end end end A_mul_Bc!(A::AbstractTriangular, B::QRCompactWYQ) = A_mul_Bc!(full!(A),B) A_mul_Bc!(A::AbstractTriangular, B::QRPackedQ) = A_mul_Bc!(full!(A),B) -A_mul_Bc(A::AbstractTriangular, B::Union{QRCompactWYQ,QRPackedQ}) = A_mul_Bc(full(A), B) +A_mul_Bc(A::AbstractTriangular, B::Union{QRCompactWYQ,QRPackedQ}) = A_mul_Bc(convert(Array, A), B) diff --git a/base/linalg/symmetric.jl b/base/linalg/symmetric.jl index 0a52b6041adbf..7ea6c99185d52 100644 --- a/base/linalg/symmetric.jl +++ b/base/linalg/symmetric.jl @@ -174,8 +174,8 @@ A_mul_B!{T<:BlasFloat,S<:StridedMatrix}(C::StridedMatrix{T}, A::StridedMatrix{T} A_mul_B!{T<:BlasComplex,S<:StridedMatrix}(C::StridedMatrix{T}, A::Hermitian{T,S}, B::StridedMatrix{T}) = BLAS.hemm!('L', A.uplo, one(T), A.data, B, zero(T), C) A_mul_B!{T<:BlasComplex,S<:StridedMatrix}(C::StridedMatrix{T}, A::StridedMatrix{T}, B::Hermitian{T,S}) = BLAS.hemm!('R', B.uplo, one(T), B.data, A, zero(T), C) -*(A::HermOrSym, B::HermOrSym) = full(A)*full(B) -*(A::StridedMatrix, B::HermOrSym) = A*full(B) +*(A::HermOrSym, B::HermOrSym) = convert(Array, A)*convert(Array, B) +*(A::StridedMatrix, B::HermOrSym) = A*convert(Array, B) bkfact(A::HermOrSym) = bkfact(A.data, Symbol(A.uplo), issymmetric(A)) factorize(A::HermOrSym) = bkfact(A) diff --git a/base/linalg/triangular.jl b/base/linalg/triangular.jl index a4acc87cd17b2..0e117702befe7 100644 --- a/base/linalg/triangular.jl +++ b/base/linalg/triangular.jl @@ -362,7 +362,7 @@ scale!(c::Number, A::Union{UpperTriangular,LowerTriangular}) = scale!(A,c) +(A::UnitLowerTriangular, B::LowerTriangular) = LowerTriangular(tril(A.data, -1) + B.data + I) +(A::UnitUpperTriangular, B::UnitUpperTriangular) = UpperTriangular(triu(A.data, 1) + triu(B.data, 1) + 2I) +(A::UnitLowerTriangular, B::UnitLowerTriangular) = LowerTriangular(tril(A.data, -1) + tril(B.data, -1) + 2I) -+(A::AbstractTriangular, B::AbstractTriangular) = full(A) + full(B) ++(A::AbstractTriangular, B::AbstractTriangular) = convert(Array, A) + convert(Array, B) -(A::UpperTriangular, B::UpperTriangular) = UpperTriangular(A.data - B.data) -(A::LowerTriangular, B::LowerTriangular) = LowerTriangular(A.data - B.data) @@ -372,15 +372,15 @@ scale!(c::Number, A::Union{UpperTriangular,LowerTriangular}) = scale!(A,c) -(A::UnitLowerTriangular, B::LowerTriangular) = LowerTriangular(tril(A.data, -1) - B.data + I) -(A::UnitUpperTriangular, B::UnitUpperTriangular) = UpperTriangular(triu(A.data, 1) - triu(B.data, 1)) -(A::UnitLowerTriangular, B::UnitLowerTriangular) = LowerTriangular(tril(A.data, -1) - tril(B.data, -1)) --(A::AbstractTriangular, B::AbstractTriangular) = full(A) - full(B) +-(A::AbstractTriangular, B::AbstractTriangular) = convert(Array, A) - convert(Array, B) ###################### # BlasFloat routines # ###################### A_mul_B!(A::Tridiagonal, B::AbstractTriangular) = A*full!(B) -A_mul_B!(C::AbstractMatrix, A::AbstractTriangular, B::Tridiagonal) = A_mul_B!(C, full(A), B) -A_mul_B!(C::AbstractMatrix, A::Tridiagonal, B::AbstractTriangular) = A_mul_B!(C, A, full(B)) +A_mul_B!(C::AbstractMatrix, A::AbstractTriangular, B::Tridiagonal) = A_mul_B!(C, convert(Array, A), B) +A_mul_B!(C::AbstractMatrix, A::Tridiagonal, B::AbstractTriangular) = A_mul_B!(C, A, convert(Array, B)) A_mul_B!(C::AbstractVector, A::AbstractTriangular, B::AbstractVector) = A_mul_B!(A, copy!(C, B)) A_mul_B!(C::AbstractMatrix, A::AbstractTriangular, B::AbstractVecOrMat) = A_mul_B!(A, copy!(C, B)) A_mul_B!(C::AbstractVecOrMat, A::AbstractTriangular, B::AbstractVecOrMat) = A_mul_B!(A, copy!(C, B)) @@ -437,7 +437,7 @@ for (t, uploc, isunitc) in ((:LowerTriangular, 'L', 'N'), elseif p == Inf return inv(LAPACK.trcon!('I', $uploc, $isunitc, A.data)) else #use fallback - return cond(full(A), p) + return cond(convert(Array, A), p) end end end @@ -1321,7 +1321,7 @@ end ## Some Triangular-Triangular cases. We might want to write taylored methods for these cases, but I'm not sure it is worth it. for t in (UpperTriangular, UnitUpperTriangular, LowerTriangular, UnitLowerTriangular) @eval begin - (*)(A::Tridiagonal, B::$t) = A_mul_B!(full(A), B) + (*)(A::Tridiagonal, B::$t) = A_mul_B!(convert(Array, A), B) end end @@ -1848,7 +1848,7 @@ eigfact(A::AbstractTriangular) = Eigen(eigvals(A), eigvecs(A)) #Generic singular systems for func in (:svd, :svdfact, :svdfact!, :svdvals) @eval begin - ($func)(A::AbstractTriangular) = ($func)(full(A)) + ($func)(A::AbstractTriangular) = ($func)(convert(Array, A)) end end diff --git a/base/linalg/tridiag.jl b/base/linalg/tridiag.jl index aee5e05483456..0e79204b5069e 100644 --- a/base/linalg/tridiag.jl +++ b/base/linalg/tridiag.jl @@ -19,7 +19,7 @@ end Construct a symmetric tridiagonal matrix from the diagonal and first sub/super-diagonal, respectively. The result is of type `SymTridiagonal` and provides efficient specialized -eigensolvers, but may be converted into a regular matrix with [`full`](:func:`full`). +eigensolvers, but may be converted into a regular matrix with [`convert(Array, _)`](:func:`convert`). """ SymTridiagonal{T}(dv::Vector{T}, ev::Vector{T}) = SymTridiagonal{T}(dv, ev) @@ -327,7 +327,7 @@ end Construct a tridiagonal matrix from the first subdiagonal, diagonal, and first superdiagonal, respectively. The result is of type `Tridiagonal` and provides efficient specialized linear -solvers, but may be converted into a regular matrix with [`full`](:func:`full`). +solvers, but may be converted into a regular matrix with [`convert(Array, _)`](:func:`convert`). The lengths of `dl` and `du` must be one less than the length of `d`. """ # Basic constructor takes in three dense vectors of same type diff --git a/base/linalg/uniformscaling.jl b/base/linalg/uniformscaling.jl index 227e41ac5dc0c..db26156fef0a2 100644 --- a/base/linalg/uniformscaling.jl +++ b/base/linalg/uniformscaling.jl @@ -61,7 +61,7 @@ for (t1, t2) in ((:UnitUpperTriangular, :UpperTriangular), end function (-)(J::UniformScaling, UL::Union{UpperTriangular,UnitUpperTriangular}) - ULnew = similar(full(UL), promote_type(eltype(J), eltype(UL))) + ULnew = similar(convert(Array, UL), promote_type(eltype(J), eltype(UL))) n = size(ULnew, 1) ULold = UL.data for j = 1:n @@ -77,7 +77,7 @@ function (-)(J::UniformScaling, UL::Union{UpperTriangular,UnitUpperTriangular}) return UpperTriangular(ULnew) end function (-)(J::UniformScaling, UL::Union{LowerTriangular,UnitLowerTriangular}) - ULnew = similar(full(UL), promote_type(eltype(J), eltype(UL))) + ULnew = similar(convert(Array, UL), promote_type(eltype(J), eltype(UL))) n = size(ULnew, 1) ULold = UL.data for j = 1:n