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

◆ ZSscSsorSolve()

Sub ZSscSsorSolve ( Uplo As  String,
N As  Long,
Omega As  Double,
Val() As  Complex,
Colptr() As  Long,
Rowind() As  Long,
D() As  Complex,
B() As  Complex,
X() As  Complex,
Optional Info As  Long,
Optional Base As  Long = -1 
)

Symmetric successive over-relaxation (SSOR) preconditioner (Complex symmetric matrices) (CSC)

Purpose
This routine is the symmetric successive over-relaxation (SSOR) preconditioner for the complex symmetric coefficient matrix A of the sparse linear equations. It solves the equation M*x = b, where M is the preconditioner matrix. Only the upper or lower trianglar part of A is referred for calculation.
Parameters
[in]Uplo= "U": Matrix A is stored in upper triangle.
= "L": Matrix A is stored in lower triangle.
[in]NDimension of preconditioner matrix. (N >= 0) (if N = 0, returns without computation)
[in]OmegaThe relaxation parameter ω. (0 < ω < 2)
[in]Val()Array Val(LVal - 1) (LVal >= Nnz)
Values of non-zero elements of matrix A. (Nnz is number of non-zero elements)
[in]Colptr()Array Colptr(LColptr - 1) (LColptr >= N + 1)
Column pointers of matrix A.
[in]Rowind()Array Rowind(LRowind - 1) (LRowind >= Nnz)
Row indices of matrix A (where Nnz is the number of nonzero elements).
[in]D()Array D(LD) (LD >= N)
Diagonal elements of preconditioner matrix M obtained by CSC_SSOR().
[in]B()Array B(LB - 1) (LB >= N)
Right hand side vector b.
[out]X()Array X(LX - 1) (LX >= N)
Solution vector x.
[out]Info(Optional)
= 0: Successful exit.
= i < 0: The (-i)-th argument is invalid.
= j > 0: Matrix is singular (j-th diagonal element is zero).
[in]Base(Optional)
Indexing of Colptr() and Rowind().
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1.
(default: Assumes 1 if Colptr(0) = 1, 0 otherwise)
Example Program
Solve the system of linear equations Ax = B by COCG method with SSOR preconditioner, where
( 0.31+0.77i 0.25+0.23i -0.81-0.83i )
A = ( 0.25+0.23i 0.26-0.26i -0.58-0.08i )
( -0.81-0.83i -0.56-0.08i 2.09+0.6i )
( 0.3941-1.2711i )
B = ( 0.0036-0.72i )
( 0.3628+1.9977i )
Sub Ex_ZCocg_Ssor_Csc()
Const N = 3, Nnz = 6, Omega = 0.9, Tol = 0.0000000001 '1.0e-10
Dim A(Nnz - 1) As Complex, Ia(N) As Long, Ja(Nnz - 1) As Long
Dim B(N - 1) As Complex, X(N - 1) As Complex
Dim XX(N - 1) As Complex, YY(N - 1) As Complex
Dim Iter As Long, Res As Double, IRev As Long, Info As Long
A(0) = Cmplx(0.31, 0.77): A(1) = Cmplx(0.25, 0.23): A(2) = Cmplx(0.26, -0.26)
A(3) = Cmplx(-0.81, -0.83): A(4) = Cmplx(-0.56, -0.08): A(5) = Cmplx(2.09, 0.6)
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) = Cmplx(0.3941, -1.2711): B(1) = Cmplx(0.0036, -0.72): B(2) = Cmplx(0.3628, 1.9977)
Dim D(N - 1) As Complex
Call ZCsxSsor(N, Omega, A(), Ia(), Ja(), D(), Info)
If Info <> 0 Then Debug.Print "Ssor Info =" + Str(Info)
IRev = 0
Do
Call ZCocg_r(N, B(), X(), Info, XX(), YY(), IRev, Iter, Res)
If IRev = 1 Then '- Matvec
Call SscZusmv("U", N, Cmplx(1), A(), Ia(), Ja(), XX(), Cmplx(0), YY())
ElseIf IRev = 3 Then '- Psolve
Call ZSscSsorSolve("U", N, Omega, A(), Ia(), Ja(), D(), YY(), XX(), Info)
If Info <> 0 Then Debug.Print "SsorSolve Info =" + Str(Info)
ElseIf IRev = 10 Then '- Check convergence
If Res < Tol Then IRev = 11
End If
Loop While IRev <> 0
Debug.Print "X ="
Debug.Print "(" + CStr(Creal(X(0))) + "," + CStr(Cimag(X(0))) + ")"
Debug.Print "(" + CStr(Creal(X(1))) + "," + CStr(Cimag(X(1))) + ")"
Debug.Print "(" + CStr(Creal(X(2))) + "," + CStr(Cimag(X(2))) + ")"
Debug.Print "Iter =" + Str(Iter) + ", Res =" + Str(Res) + ", Info =" + Str(Info)
End Sub
Function Cmplx(R As Double, Optional I As Double=0) As Complex
Building complex number
Function Cimag(A As Complex) As Double
Imaginary part of complex number
Function Creal(A As Complex) As Double
Real part of complex number
Sub SscZusmv(Uplo As String, N As Long, Alpha As Complex, Val() As Complex, Colptr() As Long, Rowind() As Long, X() As Complex, Beta As Complex, Y() As Complex, Optional Info As Long, Optional Base As Long=-1, Optional IncX As Long=1, Optional IncY As Long=1)
y <- αAx + βy (CSC) (Complex symmetric matrix)
Sub ZCocg_r(N As Long, B() As Complex, X() As Complex, Info As Long, XX() As Complex, YY() As Complex, IRev As Long, Optional Iter As Long, Optional Res As Double, Optional MaxIter As Long=500)
Solution of linear system Ax = b using conjugate orthogonal conjugate gradient (COCG) method (Complex...
Sub ZSscSsorSolve(Uplo As String, N As Long, Omega As Double, Val() As Complex, Colptr() As Long, Rowind() As Long, D() As Complex, B() As Complex, X() As Complex, Optional Info As Long, Optional Base As Long=-1)
Symmetric successive over-relaxation (SSOR) preconditioner (Complex symmetric matrices) (CSC)
Sub ZCsxSsor(N As Long, Omega As Double, Val() As Complex, Ptr() As Long, Ind() As Long, D() As Complex, Optional Info As Long, Optional Base As Long=-1)
Initialize symmetric successive over-relaxation (SSOR) preconditioner (Complex matrices) (CSC/CSR)
Example Results
X =
(-0.819999999999999,-0.94)
(0.74,0.2)
(0.48,0.21)
Iter = 3, Res = 4.80233653007367E-16, Info = 0