@@ -6,7 +6,7 @@ import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
6
6
+ , - , * , / , \ , diff, sum, cumsum, maximum, minimum, sort, sort!,
7
7
any, all, axes, isone, iterate, unique, allunique, permutedims, inv,
8
8
copy, vec, setindex!, count, == , reshape, _throw_dmrs, map, zero,
9
- show, view, in, mapreduce, one, reverse, promote_op
9
+ show, view, in, mapreduce, one, reverse, promote_op, promote_rule
10
10
11
11
import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag, transpose, adjoint, fill!,
12
12
dot, norm2, norm1, normInf, normMinusInf, normp, lmul!, rmul!, diagzero, AdjointAbsVec, TransposeAbsVec,
@@ -34,6 +34,7 @@ const AbstractFillVecOrMat{T} = Union{AbstractFillVector{T},AbstractFillMatrix{T
34
34
35
35
== (a:: AbstractFill , b:: AbstractFill ) = axes (a) == axes (b) && getindex_value (a) == getindex_value (b)
36
36
37
+
37
38
@inline function _fill_getindex (F:: AbstractFill , kj:: Integer... )
38
39
@boundscheck checkbounds (F, kj... )
39
40
getindex_value (F)
@@ -273,6 +274,14 @@ for (Typ, funcs, func) in ((:Zeros, :zeros, :zero), (:Ones, :ones, :one))
273
274
copy (F:: $Typ ) = F
274
275
275
276
getindex (F:: $Typ{T,0} ) where T = getindex_value (F)
277
+
278
+ promote_rule (:: Type{$Typ{T, N, Axes}} , :: Type{$Typ{V, N, Axes}} ) where {T,V,N,Axes} = $ Typ{promote_type (T,V),N,Axes}
279
+ function convert (:: Type{$Typ{T,N,Axes}} , A:: $Typ{V,N,Axes} ) where {T,V,N,Axes}
280
+ convert (T, getindex_value (A)) # checks that the types are convertible
281
+ $ Typ {T,N,Axes} (axes (A))
282
+ end
283
+ convert (:: Type{$Typ{T,N}} , A:: $Typ{V,N,Axes} ) where {T,V,N,Axes} = convert ($ Typ{T,N,Axes}, A)
284
+ convert (:: Type{$Typ{T}} , A:: $Typ{V,N,Axes} ) where {T,V,N,Axes} = convert ($ Typ{T,N,Axes}, A)
276
285
end
277
286
end
278
287
@@ -284,6 +293,8 @@ for TYPE in (:Fill, :AbstractFill, :Ones, :Zeros), STYPE in (:AbstractArray, :Ab
284
293
end
285
294
end
286
295
296
+ promote_rule (:: Type{<:AbstractFill{T, N, Axes}} , :: Type{<:AbstractFill{V, N, Axes}} ) where {T,V,N,Axes} = Fill{promote_type (T,V),N,Axes}
297
+
287
298
"""
288
299
fillsimilar(a::AbstractFill, axes)
289
300
0 commit comments