Skip to content

Commit d15de4d

Browse files
authored
Hermitian{<:Real} and Symmetric share conjugation (#1319)
Currently, we use a helper function `_conjugation` that produces `transpose` for `Symmetric` and `adjoint` for `Hermitian`. In this PR, we change this to produce `transpose` for real `Hermitian` matrices as well, as these should be equivalent. This improves the TTSX (time to second run) of `applytri`, as the function does not need to be recompiled. ```julia julia> using LinearAlgebra julia> A = [1 2; 3 4]; julia> S = Symmetric(A); julia> @time S + S; # first run 0.282624 seconds (608.83 k allocations: 31.942 MiB, 99.98% compilation time) # nightly 0.285233 seconds (608.83 k allocations: 31.925 MiB, 99.98% compilation time) # this PR julia> H = Hermitian(A); julia> @time H + H; # second run 0.197709 seconds (309.42 k allocations: 16.395 MiB, 6.39% gc time, 99.97% compilation time) # nightly 0.063034 seconds (48.90 k allocations: 2.900 MiB, 99.91% compilation time) # this PR ```
1 parent 8695b51 commit d15de4d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/symmetric.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ Base.dataids(A::HermOrSym) = Base.dataids(parent(A))
289289
Base.unaliascopy(A::Hermitian) = Hermitian(Base.unaliascopy(parent(A)), sym_uplo(A.uplo))
290290
Base.unaliascopy(A::Symmetric) = Symmetric(Base.unaliascopy(parent(A)), sym_uplo(A.uplo))
291291

292-
_conjugation(::Symmetric) = transpose
292+
_conjugation(::Union{Symmetric, Hermitian{<:Real}}) = transpose
293293
_conjugation(::Hermitian) = adjoint
294294

295295
diag(A::Symmetric) = symmetric.(diag(parent(A)), sym_uplo(A.uplo))

0 commit comments

Comments
 (0)