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

◆ Dssev()

Sub Dssev ( Jobz As  String,
Uplo As  String,
N As  Long,
Val() As  Double,
Ptr() As  Long,
Ind() 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 Format As  Long = 0,
Optional Mode As  Long = 1,
Optional Sigma As  Double = 0,
Optional Maxiter As  Long = 300,
Optional Tol As  Double = 0 
)

Eigenvalues and eigenvectors of a symmetric sparse matrix (implicitly restarted Lanczos method (IRLM)) (Arpack) (driver)

Purpose
Let's consider the eigenvalue problem
A*z = λ*z
where λ is eigenvalue and z is its eigenvector. A is a symmetric 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 of the sparse 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. 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
OP*x = ν*x
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]UploSpecifies whether the upper or lower triangular part of the matrix is stored.
= "U": Upper triangular part is stored.
= "L": Lower triangular part is stored.
The other triangular elements (not including diagonal elements) are ignored.
[in]NNumber 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= "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]NevNumber of eigenvalues to be computed. (0 < Nev < N)
[in]NcvNumber 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 = λ*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 = λ*z corresponding to the Ritz value approximations.
If Jobz = "N" then Z() is not referenced.
[out]InfoReturn 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, 16: 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]Sigma(Optional)
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 largest two eigenvalues and their eigenvectors of the symmetric matrix A where
( 2.2 -0.11 -0.32 )
A = ( -0.11 2.93 0.81 )
( -0.32 0.81 2.37 )
Sub Ex_Dssev()
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 D(Nev - 1) As Double, Z(N - 1, Nev - 1) As Double
Dim Nconv As Long, Info As Long
A(0) = 2.2: A(1) = -0.11: A(2) = 2.93: A(3) = -0.32: A(4) = 0.81: A(5) = 2.37
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
Call Dssev("V", "L", N, A(), Ia(), Ja(), "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 Dssev(Jobz As String, Uplo As String, N As Long, Val() As Double, Ptr() As Long, Ind() 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 Format As Long=0, Optional Mode As Long=1, Optional Sigma As Double=0, Optional Maxiter As Long=300, Optional Tol As Double=0)
Eigenvalues and eigenvectors of a symmetric sparse matrix (implicitly restarted Lanczos method (IRLM)...
Example Results
D = 2.22943643244226 3.56350401844728
Z =
-0.894521385341403 -0.200931256445799
-0.390994588677271 0.78468897753835
0.216690384632057 0.586421212707156
Nconv = 2, Info = 0