XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Dgeesx_r()

Sub Dgeesx_r ( Jobvs As  String,
Sort As  String,
Sense As  String,
N As  Long,
A() As  Double,
Sdim As  Long,
Wr() As  Double,
Wi() As  Double,
Vs() As  Double,
RConde As  Double,
RCondv As  Double,
Info As  Long,
IRev As  Long,
Selct() As  Long 
)

(Expert driver) Schur factorization of a general matrix (Reverse communication version)

Purpose
This routine computes for an n x n real nonsymmetric matrix A, the eigenvalues, the real Schur form T, and, optionally, the matrix of Schur vectors Z. This gives the Schur factorization A = Z*T*Z^T.

Optionally, it also orders the eigenvalues on the diagonal of the real Schur form so that selected eigenvalues are at the top left; computes a reciprocal condition number for the average of the selected eigenvalues (RConde); and computes a reciprocal condition number for the right invariant subspace corresponding to the selected eigenvalues (RCondv). The leading columns of Z form an orthonormal basis for this invariant subspace.

For further explanation of the reciprocal condition numbers RConde and RCondv, see Section 4.8.1 of the LAPACK Users' Guide Third Edition (where these quantities are called s and sep respectively).

A real matrix is in real Schur form if it is upper quasi-triangular with 1 x 1 and 2 x 2 blocks. 2 x 2 blocks will be standardized in the form
[ a b ]
[ c a ]
where b*c < 0. The eigenvalues of such a block are a+-sqrt(bc).

Dgeesx_r is the reverse communication version of Dgeesx.
Parameters
[in]Jobvs= "N": Schur vectors are not computed
= "V": Schur vectors are computed
[in]SortSpecifies whether or not to order the eigenvalues on the diagonal of the Schur form
= "N": Eigenvalues are not ordered
= "S": Eigenvalues are ordered (see Selct)
[in]SenseDetermines which reciprocal condition numbers are computed.
= 'N': None are computed.
= 'E': Computed for average of selected eigenvalues only.
= 'V': Computed for selected right invariant subspace only.
= 'B': Computed for both.
If Sense = "E", "V" or "B", Sort must equal "S"
[in]NOrder of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in,out]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
[in] N x N matrix A.
[out] A() has been overwritten by its real Schur form T.
[out]SdimSort = "N": Sdim = 0.
Sort = "S": Sdim = number of eigenvalues (after sorting) for which Selct(i) is true. (Complex conjugate pairs for which Selct(i) is true for either eigenvalue count as 2.)
[out]Wr()Array Wr(LWr - 1) (LWr >= N)
[out]Wi()Array Wi(LWi - 1) (LWi >= N)
Wr() and Wi() contain the real and imaginary parts, respectively, of the computed eigenvalues in the same order that they appear on the diagonal of the output Schur form T. Complex conjugate pairs of eigenvalues will appear consecutively with the eigenvalue having the positive imaginary part first.
[out]Vs()Array Vs(LVs1 - 1, LVs2 - 1) (LVs1 >= N, LVs2 >= N)
Jobvs = "V": Vs() contains the orthogonal matrix Z of Schur vectors.
Jobvs = "N": Vs() is not referenced.
[out]RCondeSense = 'E' or 'B': RConde contains the reciprocal condition number for the average of the selected eigenvalues.
Sense = 'N' or 'V': Not referenced.
[out]RCondvSense = 'V' or 'B': RCondv contains the reciprocal condition number for the selected right invariant subspace.
Sense = 'N' or 'E': Not referenced.
[out]Info= 0: Successful exit.
= -1: The argument Jobvs had an illegal value. (Jobvs <> "V" nor "N")
= -2: The argument Sort had an illegal value. (Sort <> "S" nor "N")
= -3: The argument Sense had an illegal value. (Sense <> "E", "V", "B" nor "N")
= -4: The argument N had an illegal value. (N < 0)
= -5: The argument A() is invalid.
= -7: The argument Wr() is invalid.
= -8: The argument Wi() is invalid.
= -9: The argument Vs() is invalid.
= -14: The argument Selct() is invalid.
= i (0 < i <= N): The QR algorithm failed to compute all the eigenvalues. Elements 0 to Ilo-2 and i to N-1 of Wr() and Wi() contain those eigenvalues which have converged. If Jobvs = "V", Vs() contains the matrix which reduces A to its partially converged Schur form.
= N+1: The eigenvalues could not be reordered because some eigenvalues were too close to separate (the problem is very ill-conditioned).
= N+2: After reordering, roundoff changed values of some complex eigenvalues so that leading eigenvalues in the Schur form no longer satisfy Selct(i) = true. This could also be caused by underflow due to scaling.
[in,out]IRevControl variable for reverse communication.
[in] Before first call, IRev should be initialized to zero. On succeeding calls, IRev should not be altered.
[out] If IRev is not zero, complete the following process and call this routine again.
= 0: Normal exit. See return code in Info
= 1: In the case of Sort = "S", to select eigenvalues to sort to the top left of the Schur form, the user should set Selct(i) (i = 0 To N-1). Decision should be made based on the values in Wr(i) and Wi(i) (real and imaginary part of the eigenvalue). Set Selct(i) = true (1) to select, or Selct(i) = false (0) not to select. Do not alter any variables other than Selct().
  Always IRev = 0 if Sort = "N".
[in]Selct()Array Selct(LSelct - 1) (LSelct >= N)
If IRev = 1, set Selct(i) to true (1) or false (0) to select eigenvalues for sorting.
Reference
LAPACK
Example Program
Compute all eigenvalues, Schur form T, and, Schur vectors of the general matrix A, where
( 0.20 -0.11 -0.93 )
A = ( -0.32 0.81 0.37 )
( -0.80 -0.92 -0.29 )
Sub Ex_Dgeesx_r()
Const N = 3
Dim A(N - 1, N - 1) As Double, Wr(N - 1) As Double, Wi(N - 1) As Double
Dim Sdim As Long, Vs(N - 1, N - 1) As Double
Dim IRev As Long, Selct(N - 1) As Long
Dim RConde As Double, RCondv As Double, Info As Long
A(0, 0) = 0.2: A(0, 1) = -0.11: A(0, 2) = -0.93
A(1, 0) = -0.32: A(1, 1) = 0.81: A(1, 2) = 0.37
A(2, 0) = -0.8: A(2, 1) = -0.92: A(2, 2) = -0.29
IRev = 0
Do
Call Dgeesx_r("V", "S", "B", N, A(), Sdim, Wr(), Wi(), Vs(), RConde, RCondv, Info, IRev, Selct())
If IRev = 1 Then Call Selct_r(Wr(), Wi(), Selct())
Loop While IRev <> 0
Debug.Print "Eigenvalues (r) =", Wr(0), Wr(1), Wr(2)
Debug.Print "Eigenvalues (i) =", Wi(0), Wi(1), Wi(2)
Debug.Print "Schur form T ="
Debug.Print A(0, 0), A(0, 1), A(0, 2)
Debug.Print A(1, 0), A(1, 1), A(1, 2)
Debug.Print A(2, 0), A(2, 1), A(2, 2)
Debug.Print "Schur vectors ="
Debug.Print Vs(0, 0), Vs(0, 1), Vs(0, 2)
Debug.Print Vs(1, 0), Vs(1, 1), Vs(1, 2)
Debug.Print Vs(2, 0), Vs(2, 1), Vs(2, 2)
Debug.Print "Rconde =", RConde, "Rcondv =", RCondv
Debug.Print "Sdim =", Sdim, "Info =", Info
End Sub
Sub Selct_r(Wr() As Double, Wi() As Double, Selct() As Long)
Const N = 3
Dim I As Long
For I = 0 To N - 1
Selct(I) = 0
If Wi(I) <> 0 Then Selct(I) = 1
Next
End Sub
Example Results
Eigenvalues (r) = 0.812065011925672 0.812065011925672 -0.904130023851345
Eigenvalues (i) = 0.48915757543818 -0.48915757543818 0
Schur form T =
0.812065011925672 0.540472392276116 0.684902131153596
-0.442714812131086 0.812065011925672 -0.537914483752962
0 0 -0.904130023851345
Schur vectors =
-0.492366426634308 -0.620320586279211 0.610555216308549
0.867251026977165 -0.290139488675864 0.404592057902722
-7.38306042939846E-02 0.728712184164039 0.680828608770563
Rconde = 0.894479266547508 Rcondv = 1.47509658058209
Sdim = 2 Info = 0