-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
linear algebraLinear algebraLinear algebra
Description
From https://discourse.julialang.org/t/help-creating-a-jump-variable-array/11515/8?u=tkoolen. There are cases where typeof(zero(T)) != T
, so what should the eltype
of Diagonal{T}
for such T
?
One option would be to define
Base.eltype(::Type{Diagonal{T}}) where {T} = promote_type(T, typeof(zero(T)))
but this could lead to bugs where the T
in Diagonal{T}
is assumed to be the element type. Another option is to make it so that the Diagonal
constructor converts the input vector to e.g. Vector{promote_type(T, typeof(zero(T)))}
when necessary.
Maybe erroring in the constructor when typeof(zero(T)) != T
could be another option.
Metadata
Metadata
Assignees
Labels
linear algebraLinear algebraLinear algebra