|
|
◆ Dtrevc3()
| Sub Dtrevc3 |
( |
Side As |
String, |
|
|
Howmny As |
String, |
|
|
Selct() As |
Boolean, |
|
|
N As |
Long, |
|
|
T() As |
Double, |
|
|
Vl() As |
Double, |
|
|
Vr() As |
Double, |
|
|
Mm As |
Long, |
|
|
M As |
Long, |
|
|
Info As |
Long |
|
) |
| |
Eigenvectors of quasi-triangular matrix of Schur factorization
- Purpose
- This routine computes some or all of the right and/or left eigenvectors of a real upper quasi-triangular matrix T. Matrices of this type are produced by the Schur factorization of a real general matrix: A = Q*T*Q^T, as computed by Dhseqr.
The right eigenvector x and the left eigenvector y of T corresponding to an eigenvalue w are defined by: T*x = w*x, (y^T)*T = w*(y^T)
where y^T denotes the transpose of the vector y. The eigenvalues are not input to this routine, but are read directly from the diagonal blocks of T.
This routine returns the matrices X and/or Y of right and left eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an input matrix. If Q is the orthogonal factor that reduces a matrix A to Schur form T, then Q*X and Q*Y are the matrices of right and left eigenvectors of A.
This uses a Level 3 BLAS version of the back transformation.
- Parameters
-
| [in] | Side | = "R": Compute right eigenvectors only.
= "L": Compute left eigenvectors only.
= "B": Compute both right and left eigenvectors. |
| [in] | Howmny | = "A": Compute all right and/or left eigenvectors.
= "B": Compute all right and/or left eigenvectors, backtransformed by the matrices in Vl() and/or Vr().
= "S": Compute selected right and/or left eigenvectors, as indicated by the logical array Selct(). |
| [in,out] | Selct() | Array Selct(LSelct - 1) (LSelct >= N)
If Howmny = "S", Selct() specifies the eigenvectors to be computed.
If W(j) is a real eigenvalue, the corresponding real eigenvector is computed if Selct(j) is True.
If W(j) and W(j+1) are the real and imaginary parts of a complex eigenvalue, the corresponding complex eigenvector is computed if either Selct(j) or Selct(j+1) is True, and on exit Selct(j) is set to True and Selct(j+1) is set to False.
Not referenced if Howmny = "A" or "B". |
| [in] | N | Order of the matrix A. (N >= 0) (If N = 0, returns without computation) |
| [in] | T() | Array T(LT1 - 1, LT2 - 1) (LT1 >= N, LT2 >= N)
The upper quasi-triangular matrix T in Schur canonical form. |
| [in,out] | Vl() | Array Vl(LVl1 - 1, LVl2 - 1) (LVl1 >= N, LVl2 >= MM)
[in] If Side = "L" or "B" and Howmny = "B", Vl() must contain an N x N matrix Q (usually the orthogonal matrix Q of Schur vectors returned by Dhseqr).
[out] If Side = "L" or "B", Vl() contains:
if Howmny = "A", the matrix Y of left eigenvectors of T;
if Howmny = "B", the matrix Q*Y;
if Howmny = "S", the left eigenvectors of T specified by Selct(), stored consecutively in the columns of Vl(), in the same order as their eigenvalues.
A complex eigenvector corresponding to a complex eigenvalue is stored in two consecutive columns, the first holding the real part, and the second the imaginary part.
Not referenced if Side = "R". |
| [in,out] | Vr() | Array Vr(LVr1 - 1, LVr2 - 1) (LVr1 >= N, LVr2 >= MM)
[in] If Side = "R" or "B" and Howmny = "B", Vr() must contain an N x N matrix Q (usually the orthogonal matrix Q of Schur vectors returned by Dhseqr).
[out] If Side = "R" or "B", Vr() contains:
if Howmny = "A", the matrix X of right eigenvectors of T;
if Howmny = "B", the matrix Q*X;
if Howmny = "S", the right eigenvectors of T specified by Selct(), stored consecutively in the columns of Vr(), in the same order as their eigenvalues.
A complex eigenvector corresponding to a complex eigenvalue is stored in two consecutive columns, the first holding the real part and the second the imaginary part.
Not referenced if Side = "L". |
| [in] | MM | The number of columns in the arrays Vl() and/or Vr(). (MM >= M) |
| [out] | M | The number of columns in the arrays Vl() and/or Vr() actually used to store the eigenvectors.
If Howmny = "A" or "B", M is set to N.
Each selected real eigenvector occupies one column and each selected complex eigenvector occupies two columns. |
| [out] | Info | = 0: Successful exit.
= -1: The argument Side had an illegal value. (Side <> "R", "L" nor "B")
= -2: The argument Howmny had an illegal value. (Hownmy <> "A", "B" nor "S")
= -3: The argument Selct() is invalid.
= -4: The argument N had an illegal value. (N < 0)
= -5: The argument T() is invalid.
= -6: The argument Vl() is invalid.
= -7: The argument Vr() is invalid.
= -8: The argument MM had an illegal value. (MM < M) |
- Further Details
- The algorithm used in this program is basically backward (forward) substitution, with scaling to make the the code robust against possible overflow.
Each eigenvector is normalized so that the element of largest magnitude has magnitude 1; here the magnitude of a complex number (x,y) is taken to be |x| + |y|.
- Reference
- LAPACK
- Example Program
- Compute all eigenvalues and eigenvectors 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 )
Reduces to Hessenberg form by Dgehrd, then computes eigenvalues and Schur form by Dhseqr and Dorghr. Dtrevc3 computes the eigenvectors from Schur form. Sub Ex_Dgehrd_Dhseqr_Dtrevc3()
Const N = 3
Dim A(N - 1, N - 1) As Double, Tau(N - 2) As Double
Dim Wr(N - 1) As Double, Wi(N - 1) As Double, Selct() As Boolean
Dim Vl(N - 1, N - 1) As Double, Vr(N - 1, N - 1) As Double, M As Long
Dim Ilo As Long, Ihi As Long, I As Long, J As Long, 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
Ilo = 1: Ihi = N
Call Dgehrd(N, Ilo, Ihi, A(), Tau(), Info)
If Info <> 0 Then
Debug.Print "Error in Dgehrd: Info =", Info
Exit Sub
End If
For I = 0 To N - 1
For J = 0 To N - 1
Vr(I, J) = A(I, J)
Next
Next
Call Dorghr(N, Ilo, Ihi, Vr(), Tau(), Info)
If Info <> 0 Then
Debug.Print "Error in Dorghr: Info =", Info
Exit Sub
End If
Call Dhseqr("S", "V", N, Ilo, Ihi, A(), Wr(), Wi(), Vr(), Info)
If Info <> 0 Then
Debug.Print "Error in Dhseqr: Info =", Info
Exit Sub
End If
For I = 0 To N - 1
For J = 0 To N - 1
Vl(I, J) = Vr(I, J)
Next
Next
Call Dtrevc3("B", "B", Selct(), N, A(), Vl(), Vr(), N, M, Info)
If Info <> 0 Then
Debug.Print "Error in Dtrevc3: Info =", Info
Exit Sub
End If
Debug.Print "Eigenvalues (r) =", Wr(0), Wr(1), Wr(2)
Debug.Print "Eigenvalues (i) =", Wi(0), Wi(1), Wi(2)
Debug.Print "Eigenvectors (L) ="
Debug.Print Vl(0, 0), Vl(0, 1), Vl(0, 2)
Debug.Print Vl(1, 0), Vl(1, 1), Vl(1, 2)
Debug.Print Vl(2, 0), Vl(2, 1), Vl(2, 2)
Debug.Print "Eigenvectors (R) ="
Debug.Print Vr(0, 0), Vr(0, 1), Vr(0, 2)
Debug.Print Vr(1, 0), Vr(1, 1), Vr(1, 2)
Debug.Print Vr(2, 0), Vr(2, 1), Vr(2, 2)
Debug.Print "M =", M
End Sub
Sub Dgehrd(N As Long, Ilo As Long, Ihi As Long, A() As Double, Tau() As Double, Info As Long) Reduces a real general matrix to upper Hessenberg form
Sub Dorghr(N As Long, Ilo As Long, Ihi As Long, A() As Double, Tau() As Double, Info As Long) Generates a transform matrix to Hessenberg form
Sub Dtrevc3(Side As String, Howmny As String, Selct() As Boolean, N As Long, T() As Double, Vl() As Double, Vr() As Double, Mm As Long, M As Long, Info As Long) Eigenvectors of quasi-triangular matrix of Schur factorization
Sub Dhseqr(Job As String, Compz As String, N As Long, Ilo As Long, Ihi As Long, H() As Double, Wr() As Double, Wi() As Double, Z() As Double, Info As Long) Eigenvalues and Schur factorization of Hessenberg matrix by QR method
- Example Results
Eigenvalues (r) = -0.904130023851345 0.812065011925673 0.812065011925673
Eigenvalues (i) = 0 0.48915757543818 -0.48915757543818
Eigenvectors (L) =
-0.89678255062032 -0.426130142157969 -0.33620818638403
-0.594264184393386 0.381115511928175 -0.618884488071825
-1 0.379151460023587 0.244224395790644
Eigenvectors (R) =
-0.83634228919053 -0.578201236867243 -0.117907376795369
5.97215298924774E-02 0.420188120674838 -0.579811879325162
-1 0.268818029145007 0.450298711668266
M = 3
|