|
|
◆ Dsptrd()
| Sub Dsptrd |
( |
Uplo As |
String, |
|
|
N As |
Long, |
|
|
Ap() As |
Double, |
|
|
D() As |
Double, |
|
|
E() As |
Double, |
|
|
Tau() As |
Double, |
|
|
Info As |
Long |
|
) |
| |
Reduces a real symmetric matrix stored in packed form to tridiagonal form
- Purpose
- This routine reduces a real symmetric matrix A stored in packed form to real symmetric tridiagonal form T by an orthogonal similarity transformation: Q^T * A * Q = T.
- Parameters
-
| [in] | Uplo | = "U": Upper triangle of A is stored.
= "L": Lower triangle of A is stored. |
| [in] | N | Order of the matrix A. (N >= 0) (If N = 0, returns without computation) |
| [in,out] | Ap() | Array Ap(LAp - 1) (LAp >= N(N + 1)/2)
[in] The upper or lower triangle of the symmetric matrix A, packed columnwise in a linear array. The j-th column of A is stored in the array Ap() as follows.
Uplo = "U": ap[i + j*(j + 1)/2] = a[j][i] for 0 <= i <= j <= N - 1.
Uplo = "L": ap[(i + j*(2*N - j - 1)/2] = a[j][i] for 0 <= j < = i <= N - 1.
[out] If Uplo = "U", the diagonal and first superdiagonal of Ap() are overwritten by the corresponding elements of the tridiagonal matrix T, and the elements above the first superdiagonal, with the array Tau(), represent the orthogonal matrix Q as a product of elementary reflectors. If Uplo = "L", the diagonal and first subdiagonal of Ap() are overwritten by the corresponding elements of the tridiagonal matrix T, and the elements below the first subdiagonal, with the array Tau(), represent the orthogonal matrix Q as a product of elementary reflectors. See Further Details. |
| [out] | D() | Array D(LD - 1) (LD >= N)
The diagonal elements of the tridiagonal matrix T: D(i) = Tii. |
| [out] | E() | Array E(LE - 1) (LE >= N - 1)
The off-diagonal elements of the tridiagonal matrix T: E(i) = T(i, i+1) if Uplo = "U", E(i) = T(i+1, i) if Uplo = "L". |
| [out] | Tau() | Array Tau(LTau - 1) (LTau >= N - 1)
The scalar factors of the elementary reflectors (see Further Details). |
| [out] | Info | = 0: Successful exit.
= -1: The argument Uplo had an illegal value (Uplo != "U" nor "L")
= -2: The argument N had an illegal value. (N < 0)
= -3: The argument Ap() is invalid.
= -4: The argument D() is invalid.
= -5: The argument E() is invalid.
= -6: The argument Tau() is invalid. |
- Further Details
- If Uplo = "U", the matrix Q is represented as a product of elementary reflectors
Q = H(N-1) . . . H(2) H(1).
Each H(i) has the form where tau is a real scalar, and v is a real vector with v(i+1〜N) = 0 and v(i) = 1. v(1〜i-1) is stored on exit in Ap(), overwriting A(1〜i-1, i+1), and tau in Tau(i-1).
If Uplo = "L", the matrix Q is represented as a product of elementary reflectors Q = H(1) H(2) . . . H(N-1).
Each H(i) has the form where tau is a real scalar, and v is a real vector with v(1〜i) = 0 and v(i+1) = 1; v(i+2〜N) is stored on exit in Ap(), overwriting A(i+2〜N, i), and tau in Tau(i-1).
- Reference
- LAPACK
- Example Program
- Compute all eigenvalues and eigenvectors of the symmetric matrix A, where
( 2.20 -0.11 -0.32 )
A = ( -0.11 2.93 0.81 )
( -0.32 0.81 2.37 )
Reduces to tridiagonal form by Dsptrd, then Dsterf is applied. Sub Ex_Dsptrd_Dsterf()
Const N = 3
Dim Ap(N * (N + 1) / 2) As Double, Info As Long
Dim D(N - 1) As Double, E(N - 2) As Double, Tau(N - 2) As Double
Ap(0) = 2.2
Ap(1) = -0.11: Ap(3) = 2.93
Ap(2) = -0.32: Ap(4) = 0.81: Ap(5) = 2.37
Call Dsptrd("L", N, Ap(), D(), E(), Tau(), Info)
If Info <> 0 Then
Debug.Print "Error in Dsptrd: Info =", Info
Exit Sub
End If
Call Dsterf(N, D(), E(), Info)
If Info <> 0 Then
Debug.Print "Error in Dsterf: Info =", Info
Exit Sub
End If
Debug.Print "Eigenvalues =", D(0), D(1), D(2)
End Sub
Sub Dsptrd(Uplo As String, N As Long, Ap() As Double, D() As Double, E() As Double, Tau() As Double, Info As Long) Reduces a real symmetric matrix stored in packed form to tridiagonal form
Sub Dsterf(N As Long, D() As Double, E() As Double, Info As Long) Eigenvalues of a symmetric tridiagonal matrix (QL or QR method)
- Example Results
Eigenvalues = 1.70705954911046 2.22943643244226 3.56350401844728
|