diff --git a/src/FillArrays.jl b/src/FillArrays.jl index f3d36d80..ebb4616a 100644 --- a/src/FillArrays.jl +++ b/src/FillArrays.jl @@ -461,8 +461,8 @@ for (Typ, funcs, func) in ((:Zeros, :zeros, :zero), (:Ones, :ones, :one)) end # temporary patch. should be a PR(#48895) to LinearAlgebra -Diagonal{T}(A::AbstractMatrix) where T = Diagonal{T}(diag(A)) -function convert(::Type{T}, A::AbstractMatrix) where T<:Diagonal +Diagonal{T}(A::AbstractFillMatrix) where T = Diagonal{T}(diag(A)) +function convert(::Type{T}, A::AbstractFillMatrix) where T<:Diagonal checksquare(A) isdiag(A) ? T(A) : throw(InexactError(:convert, T, A)) end diff --git a/src/fillalgebra.jl b/src/fillalgebra.jl index f05f2481..d53e6c14 100644 --- a/src/fillalgebra.jl +++ b/src/fillalgebra.jl @@ -253,12 +253,12 @@ end function +(a::ZerosVector{T}, b::AbstractRange) where {T} size(a) ≠ size(b) && throw(DimensionMismatch("dimensions must match.")) Tout = promote_type(T, eltype(b)) - return AbstractRange{Tout}(b) + return T(first(b)):T(step(b)):T(last(b)) end -function +(a::ZerosVector{T}, b::UnitRange) where {T} +function +(a::ZerosVector{T}, b::UnitRange) where {T<:Integer} size(a) ≠ size(b) && throw(DimensionMismatch("dimensions must match.")) Tout = promote_type(T, eltype(b)) - return AbstractRange{Tout}(b) + return AbstractUnitRange{T}(b) end function -(a::ZerosVector, b::AbstractRange) @@ -267,10 +267,6 @@ function -(a::ZerosVector, b::AbstractRange) end -(a::AbstractRange, b::ZerosVector) = a + b -# temporary patch. should be a PR(#48894) to julia base. -AbstractRange{T}(r::AbstractUnitRange) where {T<:Integer} = AbstractUnitRange{T}(r) -AbstractRange{T}(r::AbstractRange) where T = T(first(r)):T(step(r)):T(last(r)) - #### # norm ####