@@ -17,8 +17,8 @@ function check_hermitian(A; atol::Real = default_hermitian_tol(A), rtol::Real =
1717 return nothing
1818end
1919
20- function check_input (:: typeof (eigh_full!), A:: AbstractMatrix , DV, alg:: AbstractAlgorithm )
21- check_hermitian (A, alg)
20+ function check_input (:: typeof (eigh_full!), A:: AbstractMatrix , DV, alg:: AbstractAlgorithm ; check_hermiticity :: Bool = true )
21+ check_hermiticity && check_hermitian (A, alg)
2222 D, V = DV
2323 m = size (A, 1 )
2424 @assert D isa Diagonal && V isa AbstractMatrix
@@ -28,17 +28,17 @@ function check_input(::typeof(eigh_full!), A::AbstractMatrix, DV, alg::AbstractA
2828 @check_scalar (V, A)
2929 return nothing
3030end
31- function check_input (:: typeof (eigh_vals!), A:: AbstractMatrix , D, alg:: AbstractAlgorithm )
32- check_hermitian (A, alg)
31+ function check_input (:: typeof (eigh_vals!), A:: AbstractMatrix , D, alg:: AbstractAlgorithm ; check_hermiticity :: Bool = true )
32+ check_hermiticity && check_hermitian (A, alg)
3333 m = size (A, 1 )
3434 @assert D isa AbstractVector
3535 @check_size (D, (m,))
3636 @check_scalar (D, A, real)
3737 return nothing
3838end
3939
40- function check_input (:: typeof (eigh_full!), A:: AbstractMatrix , DV, alg:: DiagonalAlgorithm )
41- check_hermitian (A, alg)
40+ function check_input (:: typeof (eigh_full!), A:: AbstractMatrix , DV, alg:: DiagonalAlgorithm ; check_hermiticity :: Bool = true )
41+ check_hermiticity && check_hermitian (A, alg)
4242 @assert isdiag (A)
4343 m = size (A, 1 )
4444 D, V = DV
@@ -50,8 +50,8 @@ function check_input(::typeof(eigh_full!), A::AbstractMatrix, DV, alg::DiagonalA
5050 return nothing
5151end
5252
53- function check_input (:: typeof (eigh_vals!), A:: AbstractMatrix , D, alg:: DiagonalAlgorithm )
54- check_hermitian (A, alg)
53+ function check_input (:: typeof (eigh_vals!), A:: AbstractMatrix , D, alg:: DiagonalAlgorithm ; check_hermiticity :: Bool = true )
54+ check_hermiticity && check_hermitian (A, alg)
5555 @assert isdiag (A)
5656 m = size (A, 1 )
5757 @assert D isa AbstractVector
8787# DefaultAlgorithm intercepts
8888# ---------------------------
8989for f! in (:eigh_full! , :eigh_vals! , :eigh_trunc! , :eigh_trunc_no_error! )
90- @eval function $f! (A:: AbstractMatrix , alg:: DefaultAlgorithm )
91- return $ f! (A, select_algorithm ($ f!, A, nothing ; alg. kwargs... ))
90+ @eval function $f! (A:: AbstractMatrix , alg:: DefaultAlgorithm ; check_hermiticity :: Bool = true )
91+ return $ f! (A, select_algorithm ($ f!, A, nothing ; check_hermiticity, alg. kwargs... ))
9292 end
93- @eval function $f! (A:: AbstractMatrix , out, alg:: DefaultAlgorithm )
94- return $ f! (A, out, select_algorithm ($ f!, A, nothing ; alg. kwargs... ))
93+ @eval function $f! (A:: AbstractMatrix , out, alg:: DefaultAlgorithm ; check_hermiticity :: Bool = true )
94+ return $ f! (A, out, select_algorithm ($ f!, A, nothing ; check_hermiticity, alg. kwargs... ))
9595 end
9696end
9797
@@ -120,13 +120,13 @@ for (f, f_lapack!, Alg) in (
120120
121121 # MatrixAlgebraKit wrappers
122122 @eval begin
123- function eigh_full! (A:: AbstractMatrix , DV, alg:: $Alg )
124- check_input (eigh_full!, A, DV, alg)
123+ function eigh_full! (A:: AbstractMatrix , DV, alg:: $Alg ; check_hermiticity :: Bool = true )
124+ check_input (eigh_full!, A, DV, alg; check_hermiticity )
125125 $ eigh_full_f! (A, DV; alg. kwargs... )
126126 return DV
127127 end
128- function eigh_vals! (A:: AbstractMatrix , D, alg:: $Alg )
129- check_input (eigh_vals!, A, D, alg)
128+ function eigh_vals! (A:: AbstractMatrix , D, alg:: $Alg ; check_hermiticity :: Bool = true )
129+ check_input (eigh_vals!, A, D, alg; check_hermiticity )
130130 $ eigh_vals_f! (A, D; alg. kwargs... )
131131 return D
132132 end
@@ -162,22 +162,22 @@ for (f, f_lapack!, Alg) in (
162162 end
163163end
164164
165- function eigh_trunc! (A, DV, alg:: TruncatedAlgorithm )
166- D, V = eigh_full! (A, DV, alg. alg)
165+ function eigh_trunc! (A, DV, alg:: TruncatedAlgorithm ; check_hermiticity :: Bool = true )
166+ D, V = eigh_full! (A, DV, alg. alg; check_hermiticity )
167167 DVtrunc, ind = truncate (eigh_trunc!, (D, V), alg. trunc)
168168 return DVtrunc... , truncation_error! (diagview (D), ind)
169169end
170170
171- function eigh_trunc_no_error! (A, DV, alg:: TruncatedAlgorithm )
172- D, V = eigh_full! (A, DV, alg. alg)
171+ function eigh_trunc_no_error! (A, DV, alg:: TruncatedAlgorithm ; check_hermiticity :: Bool = true )
172+ D, V = eigh_full! (A, DV, alg. alg; check_hermiticity )
173173 DVtrunc, ind = truncate (eigh_trunc!, (D, V), alg. trunc)
174174 return DVtrunc
175175end
176176
177177# Diagonal logic
178178# --------------
179- function eigh_full! (A:: Diagonal , DV, alg:: DiagonalAlgorithm )
180- check_input (eigh_full!, A, DV, alg)
179+ function eigh_full! (A:: Diagonal , DV, alg:: DiagonalAlgorithm ; check_hermiticity :: Bool = true )
180+ check_input (eigh_full!, A, DV, alg; check_hermiticity )
181181 D, V = DV
182182 diagA = diagview (A)
183183 I = sortperm (diagA; by = real)
@@ -193,8 +193,8 @@ function eigh_full!(A::Diagonal, DV, alg::DiagonalAlgorithm)
193193 return D, V
194194end
195195
196- function eigh_vals! (A:: Diagonal , D, alg:: DiagonalAlgorithm )
197- check_input (eigh_vals!, A, D, alg)
196+ function eigh_vals! (A:: Diagonal , D, alg:: DiagonalAlgorithm ; check_hermiticity :: Bool = true )
197+ check_input (eigh_vals!, A, D, alg; check_hermiticity )
198198 Ad = diagview (A)
199199 if D === Ad
200200 sort! (Ad)
0 commit comments