|
◆ Zgbsv()
Sub Zgbsv |
( |
N As |
Long, |
|
|
Kl As |
Long, |
|
|
Ku As |
Long, |
|
|
Ab() 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 band matrix
- Purpose
- This routine computes the solution to a complex system of linear equations where A is a band matrix of order N with Kl sub-diagonals and Ku super-diagonals, and X and B are N x Nrhs matrices.
The LU decomposition with partial pivoting and row interchanges is used to factor A as where L is a product of permutation and unit lower triangular matrices with Kl sub-diagonals, and U is upper triangular with Kl+Ku super-diagonals. The factored form of A is then used to solve the system of equations A * X = B.
- Parameters
-
[in] | N | Number of linear equations, i.e., order of the matrix A. (N >= 0) (If N = 0, returns without computation) |
[in] | Kl | Number of sub-diagonals within the band of A. (Kl >= 0) |
[in] | Ku | Number of super-diagonals within the band of A. (Ku >= 0) |
[in,out] | Ab() | Array Ab(LAb1 - 1, LAb2 - 1) (LAb1 >= 2Kl + Ku + 1, LAb2 >= N)
[in] The matrix A in band matrix form, in rows Kl+1 to 2Kl+Ku+1; rows 1 to Kl of the array need not be set.
[out] Details of the factorization: U is stored as an upper triangular band matrix with kl+ku super-diagonals in rows 1 to Kl+Ku+1, and the multipliers used during the factorization are stored in rows Kl+Ku+2 to 2*Kl+Ku+1. See below for further details. |
[out] | IPiv() | Array IPiv(LIPiv - 1) (LIPiv >= N)
Pivot indices that define the permutation matrix P; row i of the matrix was interchanged with row IPiv(i-1). |
[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 N had an illegal value. (N < 0)
= -2: The argument Kl had an illegal value. (Kl < 0)
= -3: The argument Ku had an illegal value. (Ku < 0)
= -4: The argument Ab() is invalid.
= -5: The argument IPiv() is invalid.
= -6: The argument B() is invalid.
= -8: The argument Nrhs had an illegal value. (Nrhs < 0)
= i > 0: The i-th diagonal element of the factor U is exactly zero. The factorization has been completed, but the factor U is exactly singular, and the solution has not been 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) |
- Further Details
- The band matrix form is illustrated by the following example, when N = 6, Kl = 2, Ku = 1:
On entry:
* * * + + +
* * + + + +
* a12 a23 a34 a45 a56
a11 a22 a33 a44 a55 a66
a21 a32 a43 a54 a65 *
a31 a42 a53 a64 * *
On exit:
* * * u14 u25 u36
* * u13 u24 u35 u46
* u12 u23 u34 u45 u56
u11 u22 u33 u44 u55 u66
m21 m32 m43 m54 m65 *
m31 m42 m53 m64 * *
Array elements marked * are not used by the routine; elements marked + need not be set on entry, but are required by the routine to store elements of U because of fill-in resulting from the row interchanges.
- 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.81+0.37i 0.20-0.11i 0 )
A = ( 0.64+0.51i -0.80-0.92i -0.93-0.32i )
( 0 0.71+0.59i -0.29+0.86i )
( -0.0484+0.2644i )
B = ( -0.2644-1.0228i )
( -0.5299+1.5025i )
Sub Ex_Zgbsv()
Const N = 3, Kl = 1, Ku = 1
Dim Ab(2 * Kl + Ku, N - 1) As Complex, B(N - 1) As Complex, IPiv(N - 1) As Long
Dim ANorm As Double, RCond As Double, Info As Long
Ab(1, 1) = Cmplx(0.2, -0.11): Ab(1, 2) = Cmplx(-0.93, -0.32)
Ab(2, 0) = Cmplx(0.81, 0.37): Ab(2, 1) = Cmplx(-0.8, -0.92): Ab(2, 2) = Cmplx(-0.29, 0.86)
Ab(3, 0) = Cmplx(0.64, 0.51): Ab(3, 1) = Cmplx(0.71, 0.59)
B(0) = Cmplx(-0.0484, 0.2644): B(1) = Cmplx(-0.2644, -1.0228): B(2) = Cmplx(-0.5299, 1.5025)
ANorm = Zlangb("1", N, Kl, Ku, Ab(), , Kl)
Call Zgbsv(N, Kl, Ku, Ab(), IPiv(), B(), Info)
If Info = 0 Then Call Zgbcon("1", N, Kl, Ku, Ab(), 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.15 0.19 0.2 0.94 0.79 -0.13
RCond = 0.187722560135325
Info = 0
|