|
|
◆ Dssgv()
| Sub Dssgv |
( |
Jobz As |
String, |
|
|
Uplo As |
String, |
|
|
Uplo2 As |
String, |
|
|
N As |
Long, |
|
|
Val() As |
Double, |
|
|
Ptr() As |
Long, |
|
|
Ind() As |
Long, |
|
|
Val2() As |
Double, |
|
|
Ptr2() As |
Long, |
|
|
Ind2() As |
Long, |
|
|
Which As |
String, |
|
|
Nev As |
Long, |
|
|
Ncv As |
Long, |
|
|
D() As |
Double, |
|
|
Z() As |
Double, |
|
|
Optional Info As |
Long, |
|
|
Optional Nconv As |
Long, |
|
|
Optional Niter As |
Long, |
|
|
Optional Base As |
Long = -1, |
|
|
Optional Base2 As |
Long = -1, |
|
|
Optional Format As |
Long = 0, |
|
|
Optional Mode As |
Long = 2, |
|
|
Optional Sigma As |
Double = 0, |
|
|
Optional Maxiter As |
Long = 300, |
|
|
Optional Tol As |
Double = 0 |
|
) |
| |
Generalized eigenvalue problem of a symmetric sparse matrix (implicitly restarted Lanczos method (IRLM)) (Arpack) (driver)
- Purpose
- Let's consider the generalized eigenvalue problem where λ is eigenvalue and z is its eigenvector. A is a symmetric sparse matrix and B is a symmetric positive semi-definite sparse matrix.
This routine computes the eigenvalues λ and eigenvectors z of the above problem by implicitly restarted Lanczos method (IRLM) using Arpack routines Dsaupd and Dseupd.
The upper or lower triangular part or both (whole matrix) of the sparse matrices A and B are stored in CSC or CSR format.
This routine works in the following two modes.
(1) Regular inverse mode
When Mode = 2, this routine computes in the regular inverse mode. Largest or Smallest some eigenvalues and associated eigenvectors are computed. Sigma is not referenced.
(2) Shift and invert mode
When Mode = 3, this routine computes in the shift and invert mode. The eigenvalues closest to the specified σ (shift) can be obtained.
Let's consider the other eigenvalue problem where OP = (A - σ*M)^(-1)*M, M = B and ν is the eigenvalue of this problem. If the eigenvalue ν is obtained, the eigenvalue λ of the original problem can be computed by ν = 1/(λ - σ). Therefore, the eigenvalue λ closest to σ can be computed if the largest ν is obtained. The parameter Which specifies which eigenvalues ν are to be found. Generally, the closest eigenvalue λ to σ can be obtained by specifying "LM".
- Parameters
-
| [in] | Jobz | = 'N': Compute eigenvalues only.
= 'V': Compute eigenvalues and eigenvectors. |
| [in] | Uplo | Specifies whether the upper or lower triangular part of the matrix A is stored.
= 'U': Upper triangular part is stored.
= 'L': Lower triangular part is stored.
= 'B': Whole matrix is stored (both upper and lower parts are stored).
The other triangular elements (not including diagonal elements) are ignored. |
| [in] | Uplo2 | Specifies whether the upper or lower triangular part of the matrix B is stored.
= 'U': Upper triangular part is stored.
= 'L': Lower triangular part is stored.
= 'B': Whole matrix is stored (both upper and lower parts are stored).
The other triangular elements (not including diagonal elements) are ignored. |
| [in] | N | Number of rows and columns of the matrix. (N >= 0) (If N = 0, returns without computation) |
| [in] | Val() | Array Val(LVal - 1) (LVal >= Nnz)
Values of nonzero elements of matrix A (where Nnz is the number of nonzero elements). |
| [in] | Ptr() | Array Ptr(LPtr - 1) (LPtr >= N + 1
Column pointers (if CSC) or row pointers (if CSR) of matrix A. |
| [in] | Ind() | Array Ind(LInd - 1) (LInd >= Nnz)
Row indices (if CSC) or column indices (if CSR) of matrix A (where Nnz is the number of nonzero elements). |
| [in] | Val2() | Array Val2(LVal2 - 1) (LVal2 >= Nnz2)
Values of nonzero elements of matrix B (where Nnz is the number of nonzero elements). |
| [in] | Ptr2() | Array Ptr2(LPtr2 - 1) (LPtr2 >= N + 1
Column pointers (if CSC) or row pointers (if CSR) of matrix B. |
| [in] | Ind2() | Array Ind2(LInd2 - 1) (LInd2 >= Nnz2)
Row indices (if CSC) or column indices (if CSR) of matrix B (where Nnz is the number of nonzero elements). |
| [in] | Which | = "LA": Compute the Nev largest (algebraic) eigenvalues.
= "SA": Compute the Nev smallest (algebraic) eigenvalues.
= "LM": Compute the Nev largest (in magnitude) eigenvalues.
= "SM": Compute the Nev smallest (in magnitude) eigenvalues.
= "BE": Compute Nev eigenvalues, half from each end of the spectrum. When Nev is odd, compute one more from the high end than from the low end. |
| [in] | Nev | Number of eigenvalues to be computed. (0 < Nev < N) |
| [in] | Ncv | Number of columns of the matrix V. (Nev < Ncv <= N)
This will indicate how many Lanczos vectors are generated at each iteration (Ncv >= 2*Nev is recommended). |
| [out] | D() | Array D(LD - 1) (LD >= Nev)
Contains the Ritz value approximations to the eigenvalues of A*z = λ*B*z. The values are returned in ascending order. |
| [out] | Z() | Array Z(Ldz - 1, LZ - 1) (Ldz >= N, LZ >= Nev)
Contains the Ritz vectors (approximations to the eigenvectors) of the eigensystem A*z = λ*B*z corresponding to the Ritz value approximations.
If Jobz = "N" then Z() is not referenced. |
| [out] | Info | Return code.
= 0: Successful exit.
< 0: The (-Info)-th argument is invalid.
= 1: Maximum number of iterations taken.
= 3: No shifts could be applied during a cycle of the implicitly restarted Lanczos iteration. A possible remedy is to increase Ncv relative to Nev (Ncv >= 2*Nev is recommended).
= 11: Initial residual vector is zero.
= 12: Failed to build a Lanczos factorization.
= 13: Error return from LAPACK eigenvalue calculation.
= 14: Dsaupd did not find any eigenvalues to sufficient accuracy.
= 15 to 19: Internal code error. |
| [out] | Nconv | (Optional)
Number of Ritz values that satisfy the convergence criterion. |
| [out] | Niter | (Optional)
Number of Lanczos update iterations taken. |
| [in] | Base | (Optional)
Indexing of Ptr() and Ind().
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1.
(default: Assumes 1 if Ptr(0) = 1, 0 otherwise) |
| [in] | Base2 | (Optional)
Indexing of Ptr2() and Ind2().
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1.
(default: Assumes 1 if Ptr2(0) = 1, 0 otherwise) |
| [in] | Format | (Optional)
Sparse matrix format. (default = 0)
= 0: CSR format.
= 1: CSC format. |
| [in] | Mode | (Optional)
Computation mode. (default = 2)
= 2: Regular inverse mode.
= 3: Shift and invert mode. |
| [in] | Sigma | (Optional)
The shift (σ). Not referenced if Mode = 2. (default = 0) |
| [in] | MaxIter | (Optional)
Maximum number of Lanczos update iterations. (MaxIter > 0) (default = 300) |
| [in] | Tol | (Optional)
Stopping criterion: the acceptable relative accuracy of the Ritz value. (default = 0)
If Tol <= 0, machine precision is assumed. |
- Example Program
- Computes largest two generalized eigenvalues and their eigenvectors of the symmetric matrix A and B where
( 0.54 -0.90 -0.94 ) ( 1.18 0.54 -1.22 )
A = ( -0.90 0.70 1.04 ) B = ( 0.54 0.60 -0.71 )
( -0.94 1.04 1.65 ) ( -1.22 -0.71 1.66 )
Sub Ex_Dssgv()
Const N = 3, Nnz = 6, Ncv = N, Nev = Ncv - 1
Dim A(Nnz - 1) As Double, Ia(N) As Long, Ja(Nnz - 1) As Long
Dim B(Nnz - 1) As Double, Ib(N) As Long, Jb(Nnz - 1) As Long
Dim D(Nev - 1) As Double, Z(N - 1, Nev - 1) As Double
Dim Nconv As Long, Info As Long
A(0) = 0.54: A(1) = -0.9: A(2) = 0.7: A(3) = -0.94: A(4) = 1.04: A(5) = 1.65
Ia(0) = 0: Ia(1) = 1: Ia(2) = 3: Ia(3) = 6
Ja(0) = 0: Ja(1) = 0: Ja(2) = 1: Ja(3) = 0: Ja(4) = 1: Ja(5) = 2
B(0) = 1.18: B(1) = 0.54: B(2) = 0.6: B(3) = -1.22: B(4) = -0.71: B(5) = 1.66
Ib(0) = 0: Ib(1) = 1: Ib(2) = 3: Ib(3) = 6
Jb(0) = 0: Jb(1) = 0: Jb(2) = 1: Jb(3) = 0: Jb(4) = 1: Jb(5) = 2
Call Dssgv("V", "L", "L", N, A(), Ia(), Ja(), B(), Ib(), Jb(), "LA", Nev, Ncv, D(), Z(), Info, Nconv)
Debug.Print "D =", D(0), D(1)
Debug.Print "Z ="
Debug.Print Z(0, 0), Z(0, 1)
Debug.Print Z(1, 0), Z(1, 1)
Debug.Print Z(2, 0), Z(2, 1)
Debug.Print "Nconv =" + Str(Nconv) + ", Info =" + Str(Info)
End Sub
Sub Dssgv(Jobz As String, Uplo As String, Uplo2 As String, N As Long, Val() As Double, Ptr() As Long, Ind() As Long, Val2() As Double, Ptr2() As Long, Ind2() As Long, Which As String, Nev As Long, Ncv As Long, D() As Double, Z() As Double, Optional Info As Long, Optional Nconv As Long, Optional Niter As Long, Optional Base As Long=-1, Optional Base2 As Long=-1, Optional Format As Long=0, Optional Mode As Long=2, Optional Sigma As Double=0, Optional Maxiter As Long=300, Optional Tol As Double=0) Generalized eigenvalue problem of a symmetric sparse matrix (implicitly restarted Lanczos method (IRL...
- Example Results
D = 0.510423243055614 7.37370278804149
Z =
1.46384155786189 -9.13803098094185E-02
-0.442269445774234 1.71612038711754
1.35130854246605 0.947378600715302
Nconv = 2, Info = 0
|