|
|
◆ Dgsev()
| Sub Dgsev |
( |
Jobz As |
String, |
|
|
N As |
Long, |
|
|
Val() As |
Double, |
|
|
Ptr() As |
Long, |
|
|
Ind() As |
Long, |
|
|
Which As |
String, |
|
|
Nev As |
Long, |
|
|
Ncv As |
Long, |
|
|
Dr() As |
Double, |
|
|
Di() As |
Double, |
|
|
Z() As |
Double, |
|
|
Optional Info As |
Long, |
|
|
Optional Nconv As |
Long, |
|
|
Optional Niter As |
Long, |
|
|
Optional Base As |
Long = -1, |
|
|
Optional Format As |
Long = 0, |
|
|
Optional Mode As |
Long = 1, |
|
|
Optional Sigmar As |
Double = 0, |
|
|
Optional Sigmai As |
Double = 0, |
|
|
Optional Maxiter As |
Long = 300, |
|
|
Optional Tol As |
Double = 0 |
|
) |
| |
Eigenvalues and eigenvectors of a general sparse matrix (implicitly restarted Arnoldi method (IRAM)) (Arpack) (driver)
- Purpose
- Let's consider the eigenvalue problem where λ is eigenvalue and z is its eigenvector. A is a general sparse matrix.
This routine computes the eigenvalues λ and eigenvectors z of the above problem by implicitly restarted Arnoldi method (IRAM) using Arpack routines Dnaupd and Dneupd.
The spaese matrix A is stored in CSC or CSR format.
This routine works in the following two modes.
(1) Regular mode
When Mode = 1, this routine computes in the regular mode. Largest or smallest some eigenvalues and associated eigenvectors are computed. Sigmar and Sigmai are 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 - σ*I)^(-1) 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] | 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 input matrix (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 input matrix. |
| [in] | Ind() | Array Ind(LInd - 1) (LInd >= Nnz)
Row indices (if CSC) or column indices (if CSR) of input matrix (where Nnz is the number of nonzero elements). |
| [in] | Which | = "LM": Compute the Nev eigenvalues of largest magnitude.
= "SM": Compute the Nev eigenvalues of smallest magnitude.
= "LR": Compute the Nev eigenvalues of largest real part.
= "SR": Compute the Nev eigenvalues of smallest real part.
= "LI": Compute the Nev eigenvalues of largest imaginary part.
= "SI": Compute the Nev eigenvalues of smallest imaginary part. |
| [in] | Nev | Number of eigenvalues to be computed. (0 < Nev < N - 1) |
| [in] | Ncv | Number of columns of the matrix V. (Nev + 1 < Ncv <= N)
This will indicate how many Arnoldi vectors are generated at each iteration (Ncv >= 2*Nev is recommended). |
| [out] | Dr() | Array Dr(LDr - 1) (LDr >= Nev + 1)
Contains the Ritz value approximations to the eigenvalues of A*z = λ*z. The values are returned in ascending order. |
| [out] | Di() | Array Di(LDi - 1) (LDi >= Nev + 1)
Contains the imaginary part of the Ritz value approximations to the eigenvalues of A*z = λ*z associated with Dr(). |
| [out] | Z() | Array Z(Ldz - 1, LZ - 1) (Ldz >= N, LZ >= Nev + 1)
Contains the Ritz vectors (approximations to the eigenvectors) of the eigensystem A*z = λ*z corresponding to the Ritz value approximations.
If the Ritz values are a pair of conjugate complex numbers, the corresponding complex Ritz vectors are placed in two consecutive columns. The column corresponding to the Ritz value with a positive imaginary part contains the real part of the Ritz vector, and the next column contains the imaginary part. The Ritz vector corresponding to other Ritz value with negative imaginary part is its complex conjugate vector.
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. iparam[4] returns the number of converged Ritz values.
= 3: No shifts could be applied during a cycle of the implicitly restarted Arnoldi 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 an Arnoldi factorization.
= 13: Error return from LAPACK eigenvalue calculation.
= 14: Dnaupd 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] | Format | (Optional)
Sparse matrix format. (default = 0)
= 0: CSR format.
= 1: CSC format. |
| [in] | Mode | (Optional)
Computation mode. (default = 1)
= 1: Regular mode.
= 3: Shift and invert mode. |
| [in] | Sigmar | (Optional)
Real part of the shift (σ). Not referenced if Mode = 1. (default = 0) |
| [in] | Sigmai | (Optional)
Imaginary part of the shift (σ). Not referenced if Mode = 1. (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 the largest eigenvalue and its eigenvector of the matrix A where
( 0.2 -0.11 -0.93 )
A = ( -0.32 0.81 0.37 )
( -0.8 -0.92 -0.29 )
Sub Ex_Dgsev()
Const N = 3, Nnz = 9, Ncv = N, Nev = Ncv - 2
Dim A(Nnz - 1) As Double, Ia(N) As Long, Ja(Nnz - 1) As Long
Dim Dr(Nev) As Double, Di(Nev) As Double, Z(N - 1, Nev) As Double
Dim Nconv As Long, Info As Long, I As Long
A(0) = 0.2: A(1) = -0.11: A(2) = -0.93: A(3) = -0.32: A(4) = 0.81: A(5) = 0.37: A(6) = -0.8: A(7) = -0.92: A(8) = -0.29
Ia(0) = 0: Ia(1) = 3: Ia(2) = 6: Ia(3) = 9
Ja(0) = 0: Ja(1) = 1: Ja(2) = 2: Ja(3) = 0: Ja(4) = 1: Ja(5) = 2: Ja(6) = 0: Ja(7) = 1: Ja(8) = 2
Call Dgsev("V", N, A(), Ia(), Ja(), "LM", Nev, Ncv, Dr(), Di(), Z(), Info, Nconv)
Debug.Print "D =", Dr(0), Di(0)
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 Dgsev(Jobz As String, N As Long, Val() As Double, Ptr() As Long, Ind() As Long, Which As String, Nev As Long, Ncv As Long, Dr() As Double, Di() As Double, Z() As Double, Optional Info As Long, Optional Nconv As Long, Optional Niter As Long, Optional Base As Long=-1, Optional Format As Long=0, Optional Mode As Long=1, Optional Sigmar As Double=0, Optional Sigmai As Double=0, Optional Maxiter As Long=300, Optional Tol As Double=0) Eigenvalues and eigenvectors of a general sparse matrix (implicitly restarted Arnoldi method (IRAM)) ...
- Example Results
D = 0.812065011925673 0.48915757543818
Z =
-0.365053973674333 -0.416255621362224
0.64300369896322 -0.194693188992647
-5.47400351005566E-02 0.488989966998924
Nconv = 2, Info = 0
|