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

◆ Zhpsvx()

Sub Zhpsvx ( Fact As  String,
Uplo As  String,
N As  Long,
Ap() As  Complex,
Afp() 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 Hermitian matrix in packed form

Purpose
This routine uses the diagonal pivoting factorization A = U*D*U^H or A = L*D*L^H to computes the solution to a complex system of linear equations
A * X = B
where A is an n x n Hermitian matrix stored in packed form, 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^H, if Uplo = "U", or
    A = L * D * L^H, 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]Ap()Array Ap(LAp - 1) (LAp >= N(N + 1)/2)
N x N Hermitian matrix A in packed form. The upper or lower part is to be stored in accordance with Uplo.
[in,out]Afp()Array Afp(LAfp - 1) (LAfp >= N(N + 1)/2)
[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^H or A = L*D*L^H as computed by Zhptrf, to be stored as a packed triangular matrix in the same storage format as Ap().
[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^H or A = L*D*L^H as computed by Zhptrf, stored as a packed triangular matrix in the same storage format as Ap().
[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 Zhptrf, 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 Zhptrf, 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 Ap() is invalid.
= -5: The argument Afp() 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.11+0.93i 0.81-0.37i )
A = ( -0.11-0.93i -0.32 -0.80+0.92i )
( 0.81+0.37i -0.80-0.92i -0.29 )
( -0.1220+0.1844i )
B = ( 0.0034-0.4346i )
( 0.5339-0.1571i )
Sub Ex_Zhpsvx()
Const N = 3
Dim Ap(N * (N + 1) / 2) As Complex, Afp(N * (N + 1) / 2) 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
Ap(0) = Cmplx(0.2, 0)
Ap(1) = Cmplx(-0.11, -0.93): Ap(3) = Cmplx(-0.32, 0)
Ap(2) = Cmplx(0.81, 0.37): Ap(4) = Cmplx(-0.8, -0.92): Ap(5) = Cmplx(-0.29, 0)
B(0) = Cmplx(-0.122, 0.1844): B(1) = Cmplx(0.0034, -0.4346): B(2) = Cmplx(0.5339, -0.1571)
Call Zhpsvx("N", "L", N, Ap(), Afp(), 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
Example Results
X = 0.86 0.64 0.51 0.71 0.59 -0.15
RCond = 4.46158691608911E-02
Info = 0