-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
This is so obvious that I guess it exists elsewhere, but I don't know about it. But, if not, maybe it belongs (after some modifications) in LinearAlgebra ? ... Or some other package ?
A prototype iterator over the diagonal of a matrix is in this package.
It's called diagonal. It's like diag but does very little allocation.
julia> N = 1000;
julia> m = rand(N, N);
julia> @btime sum(diag($m)); # copy
1.718 μs (1 allocation: 7.94 KiB)
julia> @btime sum(diagonal($m)); # no copy
936.793 ns (1 allocation: 32 bytes)
Off diagonals are not yet supported.
Metadata
Metadata
Assignees
Labels
No labels