XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Dgees()

Sub Dgees ( Jobvs As  String,
Sort As  String,
Selct As  LongPtr,
N As  Long,
A() As  Double,
Sdim As  Long,
Wr() As  Double,
Wi() As  Double,
Vs() As  Double,
Info As  Long 
)

(Simple driver) Schur factorization of a general matrix

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. The leading columns of Z then form an orthonormal basis for the invariant subspace corresponding to the selected eigenvalues.

A 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).
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]SelctSort = "S": Selct is used to select eigenvalues to sort to the top left of the Schur form.
  Eigenvalues Wr(j)+-Wi(j)*i are selected if Selct(Wr(j), Wi(j)) is true (= 1); i.e., if either one of a complex conjugate pair of eigenvalues is selected, then both complex eigenvalues are selected.
  Note that a selected complex eigenvalue may no longer satisfy Selct(Wr(j), Wi(j)) = true after ordering, since ordering may change the value of complex eigenvalues (especially if the eigenvalue is ill-conditioned); in this case Info is set to N+2 (see Info below).
Sort = "N": Selct is not referenced.
[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 is true. (Complex conjugate pairs for which Selct 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]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")
= -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.
= 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 = true. This could also be caused by underflow due to scaling.
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_Dgees()
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, 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
Call Dgees("V", "S", AddressOf Selct, N, A(), Sdim, Wr(), Wi(), Vs(), Info)
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 "Sdim =", Sdim, "Info =", Info
End Sub
Function Selct(Wr As Double, Wi As Double) As Long
Selct = 0
If Wi <> 0 Then Selct = 1
End Function
Sub Dgees(Jobvs As String, Sort As String, Selct As LongPtr, N As Long, A() As Double, Sdim As Long, Wr() As Double, Wi() As Double, Vs() As Double, Info As Long)
(Simple driver) Schur factorization of a general matrix
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
Sdim = 2 Info = 0