XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Zposvx()

Sub Zposvx ( Fact As  String,
Uplo As  String,
N As  Long,
A() As  Complex,
Af() As  Complex,
Equed As  String,
S() As  Double,
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 Hermitian positive definite matrix

Purpose
This routine uses the Cholesky factorization A = U^H*U or A = L*L^H to compute the solution to a complex system of linear equations
A * X = B,
where A is an n x n Hermitian positive definite 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 = "E", real scaling factors are computed to equilibrate the system:
    diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B
    Whether or not the system will be equilibrated depends on the scaling of the matrix A, but if equilibration is used, A is overwritten by diag(S)*A*diag(S) and B by diag(S)*B.

  2. If Fact = "N" or "E", the Cholesky decomposition is used to factor the matrix A (after equilibration if Fact = "E") as
    A = U^H * U, if Uplo = "U", or
    A = L * L^H, if Uplo = "L",
    where U is an upper triangular matrix and L is a lower triangular matrix.

  3. If the leading i x i principal minor is not positive definite, 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.

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

  5. Iterative refinement is applied to improve the computed solution matrix and calculate error bounds and backward error estimates for it.

  6. If equilibration was used, the matrix X is premultiplied by diag(S) so that it solves the original system before equilibration.
Parameters
[in]FactSpecifies whether or not the factored form of the matrix A is supplied on entry, and if not, whether the matrix A should be equilibrated before it is factored.
= "F": Af() contains the factored form of A. If Equed = "Y", the matrix A has been equilibrated with scaling factors given by S(). A() and Af() will not be modified.
= "N": The matrix A will be copied to Af() and factored.
= "E": The matrix A will be equilibrated if necessary, then 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)
[in] N x N Hermitian positive definite matrix A, except if Fact = "F" and Equed = "Y", then A() must contain the equilibrated matrix diag(S)*A*diag(S). The upper or lower triangular part is referenced in accordance with Uplo.
[out] If Fact = "E" and Equed = "Y", A() is overwritten by diag(S)*A*diag(S). Otherwise, A() is not modified.
[in,out]Af()Array Af(LAf1 - 1, LAf2 - 1) (LAf1 >= N, LAf2 >= N)
[in] If Fact = "F", Af() contains the triangular factor U or L from the Cholesky factorization A = U^H*U or A = L*L^H in the same storage format as A(). If Equed = "Y", then Af() is the factored form of the equilibrated matrix diag(S)*A*diag(S).
[out] If Fact = "N", Af() returns the triangular factor U or L from the Cholesky factorization A = U^H*U or A = L*L^H of the original matrix A.
  If Fact = "E", Af() returns the triangular factor U or L from the Cholesky factorization A = U^H*U or A = L*L^H of the equilibrated matrix A (see the description of A() for the form of the equilibrated matrix).
[in,out]EquedSpecifies the form of equilibration that was done.
= "N": No equilibration.
= "Y": Equilibration was done, i.e., A has been replaced by diag(S)*A*diag(S).
[in] If Fact = "F", the form of equilibration of given matrix A.
[out] If Fact = "E", returns the result of equilibration. If Fact = "N", always returns "N".
[in,out]S()Array S(LS - 1) (LS >= N)
The scale factors for A. Not accessed if Fact = "N".
[in] If Fact = "F", the scale factors for given matrix A. (Each element > 0)
[out] If Fact = "E", the resulted scale factors.
[in,out]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)
[in] N x Nrhs right hand side matrix B.
[out] If Equed = "N", B() is not modified. If Eequed = "Y", B() is overwritten by diag(S)*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, the N x Nrhs solution matrix X to the original system of equations. Note that if Equed = "Y", A() and B() are modified on exit, and the solution to the equilibrated system is inv(diag(S))*X.
[out]RCondThe estimate of the reciprocal condition number of the matrix A after equilibration (if done). 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 Equed had an illegal value. (Fact = "F" and Equed <> "N" nor "Y")
= -7: The argument S() had an illegal value. (S(i) <= 0 when Fact = "F" and Equed = "Y")
= -8: The argument B() is invalid.
= -9: The argument X() is invalid.
= -11: The argument FErr() is invalid.
= -12: The argument BErr() is invalid.
= -14: The argument Nrhs had an illegal value. (Nrhs < 0)
= i (0 < i <= N): The leading minor of order i of A is not positive definite, so the factorization could not be completed, and the solution has not been computed. RCond = 0 is returned.
= N+1: U 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
( 2.20 -0.11+0.93i 0.81-0.37i )
A = ( -0.11-0.93i 2.32 -0.80+0.92i )
( 0.81+0.37i -0.80-0.92i 2.29 )
( 1.5980+1.4644i )
B = ( 1.3498+1.4398i )
( 2.0561-0.5441i )
Sub Ex_Zposvx()
Const N = 3
Dim A(N - 1, N - 1) As Complex, Af(N - 1, N - 1) As Complex
Dim B(N - 1) As Complex, X(N - 1) As Complex
Dim S(N - 1) As Double, Equed As String
Dim FErr(0) As Double, BErr(0) As Double
Dim RCond As Double, Info As Long
A(0, 0) = Cmplx(2.2, 0)
A(1, 0) = Cmplx(-0.11, -0.93): A(1, 1) = Cmplx(2.32, 0)
A(2, 0) = Cmplx(0.81, 0.37): A(2, 1) = Cmplx(-0.8, -0.92): A(2, 2) = Cmplx(2.29, 0)
B(0) = Cmplx(1.598, 1.4644): B(1) = Cmplx(1.3498, 1.4398): B(2) = Cmplx(2.0561, -0.5441)
Call Zposvx("N", "L", N, A(), Af(), Equed, S(), 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, "Equed = ", Equed
Debug.Print "Info =", Info
End Sub
Example Results
X = 0.86 0.64 0.51 0.71 0.59 -0.15
RCond = 8.85790434328042E-02 Equed = N
Info = 0