You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> convert(Diagonal{Int,Vector{Int}}, Diagonal(1:4))
ERROR: MethodError: no method matching Array{Int64,1}(::Diagonal{Int64,UnitRange{Int64}})
The reason is that the only constructor for instantiated Diagonal types like Diagonal{Int,Vector{Int}} (the "inner" constructor) expects its argument to be a vector. Diagonal(x) accepts both vectors and matrices.
This could be fixed by adding another inner constructor. Or we could add convert methods, since it seems at least conversion should work. Also we could add ::AbstractVector to the argument of the current inner constructor.
The text was updated successfully, but these errors were encountered:
These should be defined individually for all of these matrices (Bidiagonal, Tridiagonal, etc) right?
If this is the case, adding
Diagonal{T, V}(A::Diagonal) where {T, V<:AbstractVector{T}} = Diagonal(convert(V, A.diag)) and analogous ones for the other types should be sufficient.
Playing with #563, I discovered this:
The reason is that the only constructor for instantiated Diagonal types like
Diagonal{Int,Vector{Int}}
(the "inner" constructor) expects its argument to be a vector.Diagonal(x)
accepts both vectors and matrices.This could be fixed by adding another inner constructor. Or we could add
convert
methods, since it seems at least conversion should work. Also we could add::AbstractVector
to the argument of the current inner constructor.The text was updated successfully, but these errors were encountered: