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

◆ Zsysvx()

Sub Zsysvx ( Fact As  String,
Uplo As  String,
N As  Long,
A() As  Complex,
Af() As  Complex,
IPiv() As  Long,
B() As  Complex,
X() As  Complex,
RCond As  Double,
FErr() As  Double,
BErr() As  Double,
Info As  Long,
Optional Nrhs As  Long = 1 
)

(Expert driver) Solution to system of linear equations AX = B for a complex symmetric matrix

Purpose
This routine uses the diagonal pivoting factorization to computes the solution to a complex system of linear equations
A * X = B
where A is an n x n symmetric matrix, and X and B are n x nrhs matrices.
Error bounds on the solution and a condition estimate are also provided.
Description
The following steps are performed:

  1. If Fact = "N", the diagonal pivoting method is used to factor A. The form of the factorization is
    A = U * D * U^T, if Uplo = "U", or
    A = L * D * L^T, if Uplo = "L",
    where U (or L) is a product of permutation and unit upper (lower) triangular matrices, and D is symmetric and block diagonal with 1 x 1 and 2 x 2 diagonal blocks.

  2. If some i-th diagonal element of D = 0, so that D is exactly singular, then the routine returns with Info = i. Otherwise, the factored form of A is used to estimate the condition number of the matrix A. If the reciprocal of the condition number is less than machine precision, Info = n+1 is returned as a warning, but the routine still goes on to solve for X and compute error bounds as described below.

  3. The system of equations is solved for X using the factored form of A.

  4. Iterative refinement is applied to improve the computed solution matrix and calculate error bounds and backward error estimates for it.
Parameters
[in]FactSpecifies whether or not the factored form of A has been supplied on entry.
= "F": Af() and IPiv() contain the factored form of A. Af() and IPiv() will not be modified.
= "N": The matrix A will be copied to Af() and factored.
[in]Uplo= "U": Upper triangle of A is stored.
= "L": Lower triangle of A is stored.
[in]NNumber of linear equations, i.e., order of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
N x N symmetric matrix A. The upper or lower triangular part is to be referenced in accordance with Uplo.
[in,out]Af()Array Af(LAf1 - 1, LAf2 - 1) (LAf1 >= N, LAf2 >= N)
[in] If Fact = "F", the block diagonal matrix D and the multipliers used to obtain the factor U or L from the factorization A = U*D*U^T or A = L*D*L^T as computed by Zsytrf.
[out] If Fact = "N", the block diagonal matrix D and the multipliers used to obtain the factor U or L from the factorization A = U*D*U^T or A = L*D*L^T.
[in,out]IPiv()Array IPiv(LIPiv - 1) (LIPiv >= N)
[in] If Fact = "F", details of the interchanges and the block structure of D, as determined by Zsytrf, are to be stored. If IPiv(k-1) > 0, then rows and columns k and IPiv(k-1) were interchanged, and k-th diagonal of D is a 1 x 1 diagonal block.
  If Uplo = "U" and IPiv(k-1) = IPiv(k-2) < 0, then rows and columns k-1 and -IPiv(k-1) were interchanged and (k-1)-th diagonal of D is a 2 x 2 diagonal block.
  If Uplo = "L" and IPiv(k-1) = IPiv(k) < 0, then rows and columns k+1 and -IPiv(k-1) were interchanged and k-th diagonal of D is a 2 x 2 diagonal block.
[out] If Fact = "N", details of the interchanges and the block structure of D, as determined by Zsytrf, are returned.
[in]B()Array B(LB1 - 1, LB2 - 1) (LB1 >= max(1, N), LB2 >= Nrhs) (2D array) or B(LB - 1) (LB >= max(1, N), Nrhs = 1) (1D array)
N x Nrhs matrix of right hand side matrix B.
[out]X()Array X(LX1 - 1, LX2 - 1) (LX1 >= max(1, N), LX2 >= Nrhs) (2D array) or X(LX - 1) (LX >= max(1, N), Nrhs = 1) (1D array)
If Info = 0 or Info = N+1, N x Nrhs solution matrix X.
[out]RCondThe estimate of the reciprocal condition number of the matrix A. If RCond is less than the machine precision (in particular, if RCond = 0), the matrix is singular to working precision. This condition is indicated by a return code of Info > 0.
[out]FErr()Array FErr(LFErr - 1) (LFErr >= Nrhs)
The estimated forward error bound for each solution vector X(j) (the j-th column of the solution matrix X). If Xtrue is the true solution corresponding to X(j), FErr(j-1) is an estimated upper bound for the magnitude of the largest element in (X(j) - Xtrue) divided by the magnitude of the largest element in X(j). The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.
[out]BErr()Array BErr(LBErr - 1) (LBErr >= Nrhs)
The componentwise relative backward error of each solution vector X(j) (i.e., the smallest relative change in any element of A or B that makes X(j) an exact solution).
[out]Info= 0: Successful exit.
= -1: The argument Fact had an illegal value. (Fact <> "F", "N" nor "E")
= -2: The argument Uplo had an illegal value. (Uplo <> "U" nor "L")
= -3: The argument N had an illegal value. (N < 0)
= -4: The argument A() is invalid.
= -5: The argument Af() is invalid.
= -6: The argument IPiv() is invalid.
= -7: The argument B() is invalid.
= -8: The argument X() is invalid.
= -10: The argument FErr() is invalid.
= -11: The argument BErr() is invalid.
= -13: The argument Nrhs had an illegal value. (Nrhs < 0)
= i (0 < i <= N): The i-th element of the factor D is exactly zero. The factorization has been completed, but the factor D is exactly singular, so the solution and error bounds could not be computed. RCond = 0 is returned.
= N+1: D is nonsingular, but rcond is less than machine precision, meaning that the matrix is singular to working precision. Nevertheless, the solution and error bounds are computed because there are a number of situations where the computed solution can be more accurate than the value of RCond would suggest.
[in]Nrhs(Optional)
Number of right hand sides, i.e., number of columns of the matrix B. (Nrhs >= 0) (If Nrhs = 0, returns without computation) (default = 1)
Reference
LAPACK
Example Program
Solve the system of linear equations Ax = B and estimate the reciprocal of the condition number (RCond) of A, where
( 0.20-0.11i -0.93-0.32i -0.80-0.92i )
A = ( -0.93-0.32i 0.81+0.37i -0.29+0.86i )
( -0.80-0.92i -0.29+0.86i 0.64+0.51i )
( 1.1120-1.0248i )
B = ( -1.5297-0.7781i )
( -0.4965-0.6057i )
Sub Ex_Zsysvx()
Const N = 3
Dim A(N - 1, N - 1) As Complex, Af(N - 1, N - 1) As Complex, IPiv(N - 1) As Long
Dim B(N - 1) As Complex, X(N - 1) As Complex
Dim FErr(0) As Double, BErr(0) As Double
Dim RCond As Double, Info As Long
A(0, 0) = Cmplx(0.2, -0.11)
A(1, 0) = Cmplx(-0.93, -0.32): A(1, 1) = Cmplx(0.81, 0.37)
A(2, 0) = Cmplx(-0.8, -0.92): A(2, 1) = Cmplx(-0.29, 0.86): A(2, 2) = Cmplx(0.64, 0.51)
B(0) = Cmplx(1.112, -1.0248): B(1) = Cmplx(-1.5297, -0.7781): B(2) = Cmplx(-0.4965, -0.6057)
Call Zsysvx("N", "L", N, A(), Af(), IPiv(), B(), X(), RCond, FErr(), BErr(), Info)
Debug.Print "X =",
Debug.Print Creal(X(0)), Cimag(X(0)), Creal(X(1)), Cimag(X(1)), Creal(X(2)), Cimag(X(2))
Debug.Print "RCond =", RCond
Debug.Print "Info =", 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 Zsysvx(Fact As String, Uplo As String, N As Long, A() As Complex, Af() As Complex, IPiv() As Long, B() As Complex, X() As Complex, RCond As Double, FErr() As Double, BErr() As Double, Info As Long, Optional Nrhs As Long=1)
(Expert driver) Solution to system of linear equations AX = B for a complex symmetric matrix
Example Results
X = 0.71 0.59 -0.15 0.19 0.2 0.94
RCond = 0.182788206403613
Info = 0