Skip to content

Commit

Permalink
Replace full(X) calls with convert(Array, X) throughout base/linalg.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacha0 committed Jul 16, 2016
1 parent 4dd7355 commit bd3c3ac
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 50 deletions.
16 changes: 8 additions & 8 deletions base/linalg/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -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**
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions base/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]...)
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/hessenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions base/linalg/lq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.τ))

Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ 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]
L[i, 1:i - 1] = tmp
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
Expand Down
7 changes: 5 additions & 2 deletions base/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down
20 changes: 10 additions & 10 deletions base/linalg/special.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions base/linalg/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions base/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions base/linalg/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bd3c3ac

Please sign in to comment.