-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reroute algebraic functions for
Symmetric
/Hermitian
through trian…
…gular (#52942) This ensures that only the triangular indices are accessed for strided parent matrices. Fix #52895 ```julia julia> M = Matrix{Complex{BigFloat}}(undef, 2, 2); julia> M[1,1] = M[2,2] = M[1,2] = 2; julia> H = Hermitian(M) 2×2 Hermitian{Complex{BigFloat}, Matrix{Complex{BigFloat}}}: 2.0+0.0im 2.0+0.0im 2.0-0.0im 2.0+0.0im julia> H + H # works after this 2×2 Hermitian{Complex{BigFloat}, Matrix{Complex{BigFloat}}}: 4.0+0.0im 4.0+0.0im 4.0-0.0im 4.0+0.0im ``` This also provides a speed-up in several common cases (allocations mentioned only when they differ): ```julia julia> H = Hermitian(rand(ComplexF64,1000,1000)); julia> H2 = Hermitian(rand(ComplexF64,1000,1000),:L); ``` | Operation | master | PR | | ---- | ---- | ---- | |`-H` |2.247 ms | 1.384 ms | | `real(H)` |1.544 ms |1.175 ms | |`H + H` |2.288 ms |1.978 ms | |`H + H2` |5.139 ms |3.287 ms | | `isdiag(H)` |23.042 ns (1 allocation: 16 bytes) |16.778 ns (0 allocations: 0 bytes) | I'm not entirely certain why `isdiag(H)` allocates on master, as union splitting should handle this automatically, but manually splitting the union appears to help.
- Loading branch information
Showing
2 changed files
with
88 additions
and
27 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