forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
copyto!
in converting Diagonal
/Bidiagonal
/Tridiagonal
to …
…`Matrix` (JuliaLang#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.
- Loading branch information
Showing
7 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters