Skip to content

Commit a5aeb13

Browse files
topolaritydkarrasch
authored andcommitted
Improve type-stability of eigencopy_oftype (#1419)
Without the `where` clause, this can end up inferred / invoked as e.g. `eigencopy_oftype(::Symmetric{ComplexF64, ...}, ::Type)::Matrix` (eltype is lost)
1 parent ad868c7 commit a5aeb13

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/symmetriceigen.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# preserve HermOrSym wrapper
44
# Call `copytrito!` instead of `copy_similar` to only copy the matching triangular half
5-
eigencopy_oftype(A::Hermitian, S) = Hermitian(copytrito!(similar(parent(A), S, size(A)), A.data, A.uplo), sym_uplo(A.uplo))
6-
eigencopy_oftype(A::Symmetric, S) = Symmetric(copytrito!(similar(parent(A), S, size(A)), A.data, A.uplo), sym_uplo(A.uplo))
7-
eigencopy_oftype(A::Symmetric{<:Complex}, S) = copyto!(similar(parent(A), S), A)
5+
eigencopy_oftype(A::Hermitian, ::Type{S}) where S = Hermitian(copytrito!(similar(parent(A), S, size(A)), A.data, A.uplo), sym_uplo(A.uplo))
6+
eigencopy_oftype(A::Symmetric, ::Type{S}) where S = Symmetric(copytrito!(similar(parent(A), S, size(A)), A.data, A.uplo), sym_uplo(A.uplo))
7+
eigencopy_oftype(A::Symmetric{<:Complex}, ::Type{S}) where S = copyto!(similar(parent(A), S), A)
88

99
"""
1010
default_eigen_alg(A)

0 commit comments

Comments
 (0)