@@ -39,7 +39,7 @@ function rfeigen(A::AbstractMatrix{T},
3939 factor = lu,
4040 scale = true ,
4141 verbose = false
42- ) where {T,Tλ,Tx}
42+ ) where {T,Tλ <: Union{Real,Complex} ,Tx}
4343 Tr = promote_type (promote_type (Tx,DT),Tλ)
4444 res = _rfeigen (A, x, λ, Tr, factor, maxiter, tol, scale, verbose)
4545 return res
@@ -59,7 +59,7 @@ function rfeigen(A::AbstractMatrix{T},
5959 factor = lu,
6060 scale = true ,
6161 verbose = false
62- ) where {T,Tλ}
62+ ) where {T,Tλ <: Union{Real,Complex} }
6363 # CHECKME: is this condition adequate?
6464 if issymmetric (A) && (Tλ <: Real )
6565 Tx = Tλ
@@ -148,20 +148,25 @@ end
148148"""
149149 rfeigen(A, S::Schur, idxλ, DT, maxiter=5) -> vals, vecs, status
150150
151- Improves the precision of a cluster of eigenvalues of matrix `A`
152- via multi-precision iterative refinement, using more-precise real type `DT`.
151+ Improves the precision of a cluster of eigenvalues of square matrix `A`
152+ via multi-precision iterative refinement, using more-precise real type `DT`,
153+ using a pre-computed Schur decomposition `S`.
153154Returns improved estimates of eigenvalues and vectors generating
154155the corresponding invariant subspace.
155156
156157This method works on the set of eigenvalues in `S.values` indexed by `idxλ`.
157158It is designed to handle (nearly) defective cases, but will fail if
158159the matrix is extremely non-normal or the initial estimates are poor.
159- Note that `S` must be a true Schur decomposition, not a "real Schur".
160+
161+ If `S` is a quasi-triangular "real Schur", it will be converted to
162+ a complex upper-triangular Schur decomposition. `S` may be a partial
163+ decomposition (i.e. fewer than `size(A,1)` vectors).
160164"""
161165function rfeigen (A:: AbstractMatrix{T} , S:: Schur{TS} , idxλ,
162166 DT = widen (real (T)), maxiter= 5 ;
163167 tol = 1 , verbose = false ) where {T, TS <: Complex }
164168 n = size (A,1 )
169+ ns = size (S. T,1 )
165170 m = length (idxλ)
166171 λ = [S. values[idxλ[i]] for i in 1 : m]
167172 Tw = promote_type (T,eltype (λ))
@@ -174,8 +179,8 @@ function rfeigen(A::AbstractMatrix{T}, S::Schur{TS}, idxλ,
174179 # M is an upper-triangular matrix of mixing coefficients
175180
176181 # Most of the work is in the space of Schur vectors
177- Z = zeros (Tw, n , m)
178- z = zeros (Tw, n )
182+ Z = zeros (Tw, ns , m)
183+ z = zeros (Tw, ns )
179184 idxz = Vector {Int} (undef, m)
180185
181186 k = idxλ[1 ]
@@ -195,7 +200,9 @@ function rfeigen(A::AbstractMatrix{T}, S::Schur{TS}, idxλ,
195200 for l= 2 : m
196201 kp = k
197202 k = idxλ[l]
198- @assert k > kp
203+ if k <= kp
204+ throw (ArgumentError (" idxλ must be an increasing sequence" ))
205+ end
199206 x0 = (S. T[1 : k- 1 ,1 : k- 1 ] - λ[l]* I) \ S. T[1 : k- 1 ,k]
200207 X1 = (S. T[1 : k- 1 ,1 : k- 1 ] - λ[l]* I) \ Z[1 : k- 1 ,1 : l- 1 ]
201208 z[1 : k- 1 ] .= - x0
@@ -329,3 +336,9 @@ function rfeigen(A::AbstractMatrix{T}, S::Schur{TS}, idxλ,
329336 λnew = λbar .+ dλ
330337 λnew, Xnew, status
331338end
339+
340+ function rfeigen (A:: AbstractMatrix{T} , S:: Schur{TS} , idxλ, DT = widen (real (T)), maxiter= 5 ;
341+ kwargs... ) where {T, TS <: Real }
342+ Sc = Schur {Complex{TS}} (S)
343+ rfeigen (A, Sc, idxλ, DT, maxiter; kwargs... )
344+ end
0 commit comments