@@ -6,10 +6,16 @@ eigencopy_oftype(A::Hermitian, S) = Hermitian(copytrito!(similar(parent(A), S, s
6
6
eigencopy_oftype (A:: Symmetric , S) = Symmetric (copytrito! (similar (parent (A), S, size (A)), A. data, A. uplo), sym_uplo (A. uplo))
7
7
eigencopy_oftype (A:: Symmetric{<:Complex} , S) = copyto! (similar (parent (A), S), A)
8
8
9
- default_eigen_alg (A) = DivideAndConquer ()
9
+ """
10
+ default_eigen_alg(A)
11
+
12
+ Return the default algorithm used to solve the eigensystem `A v = λ v` for a symmetric matrix `A`.
13
+ Defaults to `LinearAlegbra.DivideAndConquer()`, which corresponds to the LAPACK function `LAPACK.syevd!`.
14
+ """
15
+ default_eigen_alg (@nospecialize (A)) = DivideAndConquer ()
10
16
11
17
# Eigensolvers for symmetric and Hermitian matrices
12
- function eigen! (A:: RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix} , alg:: Algorithm = default_eigen_alg (A); sortby:: Union{Function,Nothing} = nothing )
18
+ function eigen! (A:: RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix} ; alg:: Algorithm = default_eigen_alg (A), sortby:: Union{Function,Nothing} = nothing )
13
19
if alg === DivideAndConquer ()
14
20
Eigen (sorteig! (LAPACK. syevd! (' V' , A. uplo, A. data)... , sortby)... )
15
21
elseif alg === QRIteration ()
@@ -22,7 +28,7 @@ function eigen!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}, alg::Algo
22
28
end
23
29
24
30
"""
25
- eigen(A::Union{Hermitian, Symmetric}, alg::Algorithm = default_eigen_alg(A)) -> Eigen
31
+ eigen(A::Union{Hermitian, Symmetric}; alg::LinearAlgebra. Algorithm = LinearAlgebra. default_eigen_alg(A)) -> Eigen
26
32
27
33
Compute the eigenvalue decomposition of `A`, returning an [`Eigen`](@ref) factorization object `F`
28
34
which contains the eigenvalues in `F.values` and the eigenvectors in the columns of the
@@ -45,19 +51,19 @@ The default `alg` used may change in the future.
45
51
46
52
The following functions are available for `Eigen` objects: [`inv`](@ref), [`det`](@ref), and [`isposdef`](@ref).
47
53
"""
48
- function eigen (A:: RealHermSymComplexHerm , alg:: Algorithm = default_eigen_alg (A); sortby:: Union{Function,Nothing} = nothing )
49
- _eigen (A, alg; sortby)
54
+ function eigen (A:: RealHermSymComplexHerm ; alg:: Algorithm = default_eigen_alg (A), sortby:: Union{Function,Nothing} = nothing )
55
+ _eigen (A; alg, sortby)
50
56
end
51
57
52
58
# we dispatch on the eltype in an internal method to avoid ambiguities
53
- function _eigen (A:: RealHermSymComplexHerm , alg:: Algorithm ; sortby)
59
+ function _eigen (A:: RealHermSymComplexHerm ; alg:: Algorithm , sortby)
54
60
S = eigtype (eltype (A))
55
- eigen! (eigencopy_oftype (A, S), alg; sortby)
61
+ eigen! (eigencopy_oftype (A, S); alg, sortby)
56
62
end
57
63
58
- function _eigen (A:: RealHermSymComplexHerm{Float16} , alg:: Algorithm ; sortby:: Union{Function,Nothing} = nothing )
64
+ function _eigen (A:: RealHermSymComplexHerm{Float16} ; alg:: Algorithm , sortby:: Union{Function,Nothing} = nothing )
59
65
S = eigtype (eltype (A))
60
- E = eigen! (eigencopy_oftype (A, S), alg, sortby = sortby)
66
+ E = eigen! (eigencopy_oftype (A, S); alg, sortby)
61
67
values = convert (AbstractVector{Float16}, E. values)
62
68
vectors = convert (AbstractMatrix{isreal (E. vectors) ? Float16 : Complex{Float16}}, E. vectors)
63
69
return Eigen (values, vectors)
@@ -114,7 +120,7 @@ function eigen(A::RealHermSymComplexHerm, vl::Real, vh::Real)
114
120
end
115
121
116
122
117
- function eigvals! (A:: RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix} , alg:: Algorithm = default_eigen_alg (A); sortby:: Union{Function,Nothing} = nothing )
123
+ function eigvals! (A:: RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix} ; alg:: Algorithm = default_eigen_alg (A), sortby:: Union{Function,Nothing} = nothing )
118
124
vals:: Vector{real(eltype(A))} = if alg === DivideAndConquer ()
119
125
LAPACK. syevd! (' N' , A. uplo, A. data)
120
126
elseif alg === QRIteration ()
@@ -129,7 +135,7 @@ function eigvals!(A::RealHermSymComplexHerm{<:BlasReal,<:StridedMatrix}, alg::Al
129
135
end
130
136
131
137
"""
132
- eigvals(A::Union{Hermitian, Symmetric}, alg::Algorithm = default_eigen_alg(A))) -> values
138
+ eigvals(A::Union{Hermitian, Symmetric}; alg::Algorithm = default_eigen_alg(A))) -> values
133
139
134
140
Return the eigenvalues of `A`.
135
141
@@ -143,9 +149,9 @@ a comparison of the accuracy and performance of different methods.
143
149
144
150
The default `alg` used may change in the future.
145
151
"""
146
- function eigvals (A:: RealHermSymComplexHerm , alg:: Algorithm = default_eigen_alg (A); sortby:: Union{Function,Nothing} = nothing )
152
+ function eigvals (A:: RealHermSymComplexHerm ; alg:: Algorithm = default_eigen_alg (A), sortby:: Union{Function,Nothing} = nothing )
147
153
S = eigtype (eltype (A))
148
- eigvals! (eigencopy_oftype (A, S), alg; sortby)
154
+ eigvals! (eigencopy_oftype (A, S); alg, sortby)
149
155
end
150
156
151
157
0 commit comments