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
Use copyto! in converting Diagonal/Bidiagonal/Tridiagonal to Matrix (#53912)
With this, we may convert a structured matrix to `Matrix` even if its
`eltype` doesn't support `zero(T)`, as long as we may index into the
matrix and the elements have `zero` defined for themselves. This makes
the following work:
```julia
julia> D = Diagonal(fill(Diagonal([1,3]), 2))
2×2 Diagonal{Diagonal{Int64, Vector{Int64}}, Vector{Diagonal{Int64, Vector{Int64}}}}:
[1 0; 0 3] ⋅
⋅ [1 0; 0 3]
julia> Matrix{eltype(D)}(D)
2×2 Matrix{Diagonal{Int64, Vector{Int64}}}:
[1 0; 0 3] [0 0; 0 0]
[0 0; 0 0] [1 0; 0 3]
```
We also may materialize partly initialized matrices:
```julia
julia> D = Diagonal(Vector{BigInt}(undef, 2))
2×2 Diagonal{BigInt, Vector{BigInt}}:
#undef ⋅
⋅ #undef
julia> Matrix{eltype(D)}(D)
2×2 Matrix{BigInt}:
#undef 0
0 #undef
```
The performance seems identical for numeric matrices.
0 commit comments