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

◆ Zspsv()

Sub Zspsv ( Uplo As  String,
N As  Long,
Ap() As  Complex,
IPiv() As  Long,
B() As  Complex,
Info As  Long,
Optional Nrhs As  Long = 1 
)

(Simple driver) Solution to system of linear equations AX = B for a complex symmetric matrix in packed form

Purpose
This routine computes the solution to a complex system of linear equations
A * X = B
where A is an n x n symmetric matrix stored in packed form, and X and B are n x nrhs matrices.

The diagonal pivoting method is used to factor A as
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. The factored form of A is then used to solve the system of equations A * X = B.
Parameters
[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,out]Ap()Array Ap(LAp - 1) (LAp >= N(N + 1)/2)
[in] N x N symmetric matrix A in packed form. The upper or lower part is to be stored in accordance with Uplo.
[out] 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 Zsptrf, stored as a packed triangular matrix in the same storage format as A.
[out]IPiv()Array IPiv(LIPiv - 1) (LIPiv >= N)
Details of the interchanges and the block structure of D, as determined by Zsptrf. 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.
[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 matrix of right hand side matrix B.
[out] If Info = 0, the N x Nrhs solution matrix X.
[out]Info= 0: Successful exit.
= -1: The argument Uplo had an illegal value. (Uplo <> "U" nor "L")
= -2: The argument N had an illegal value. (N < 0)
= -3: The argument Ap() is invalid.
= -4: The argument IPiv() is invalid.
= -5: The argument B() is invalid.
= -7: The argument Nrhs had an illegal value. (Nrhs < 0)
= i > 0: The i-th element of D is exactly zero. The factorization has been completed, but the block diagonal matrix D is exactly singular, so the solution could not be computed.
[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_Zspsv()
Const N As Long = 3
Dim Ap(N * (N + 1) / 2) As Complex, B(N - 1) As Complex, IPiv(N - 1) As Long
Dim ANorm As Double, RCond As Double, Info As Long
Ap(0) = Cmplx(0.2, -0.11)
Ap(1) = Cmplx(-0.93, -0.32): Ap(3) = Cmplx(0.81, 0.37)
Ap(2) = Cmplx(-0.8, -0.92): Ap(4) = Cmplx(-0.29, 0.86): Ap(5) = 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)
ANorm = Zlansp("1", "L", N, Ap())
Call Zspsv("L", N, Ap(), IPiv(), B(), Info)
If Info = 0 Then Call Zspcon("L", N, Ap(), IPiv(), ANorm, RCond, Info)
Debug.Print "X =",
Debug.Print Creal(B(0)), Cimag(B(0)), Creal(B(1)), Cimag(B(1)), Creal(B(2)), Cimag(B(2))
Debug.Print "RCond =", RCond
Debug.Print "Info =", Info
End Sub
Example Results
X = 0.71 0.59 -0.15 0.19 0.2 0.94
RCond = 0.182788206403613
Info = 0