|
|
◆ Dgssv()
| Sub Dgssv |
( |
N As |
Long, |
|
|
Val() As |
Double, |
|
|
Ptr() As |
Long, |
|
|
Ind() As |
Long, |
|
|
B() As |
Double, |
|
|
RCond As |
Double, |
|
|
Optional Info As |
Long, |
|
|
Optional Format As |
Long = 0, |
|
|
Optional Base As |
Long = -1, |
|
|
Optional Nrhs As |
Long = 1, |
|
|
Optional ColPerm As |
String = "A", |
|
|
Optional Thresh As |
Double = 1, |
|
|
Optional SymMode As |
String = "N" |
|
) |
| |
Solves the system of linear equations A*X = B (direct method) (sparse matrix) (SuperLU) (simple driver)
- Purpose
- This routine solves the system of linear equations A*X = B, using the LU factorization, where A is a general N x N sparse matrix. It performs the following steps:
- If A is stored column-wise (CSC):
1.1. Permute the columns of A, forming A*Pc, where Pc is a permutation matrix.
1.2. Factor A as Pr*A*Pc = L*U with the permutation Pr determined by Gaussian elimination with partial pivoting. L is unit lower triangular with offdiagonal entries bounded by 1 in magnitude, and U is upper triangular.
1.3. Solve the system of equations A*X = B using the factored form of A.
- If A is stored row-wise (CSR), apply the above algorithm to the transpose of A:
2.1. Permute columns of transpose(A) (rows of A), forming transpose(A)*Pc, where Pc is a permutation matrix.
2.2. Factor A as Pr*transpose(A)*Pc = L*U with the permutation Pr determined by Gaussian elimination with partial pivoting. L is unit lower triangular with offdiagonal entries bounded by 1 in magnitude, and U is upper triangular.
2.3. Solve the system of equations A*X = B using the factored form of A.
- Parameters
-
| [in] | N | Number of rows and columns of the matrix A. (N >= 0) (If N = 0, returns without computation) |
| [in] | Val() | Array Val(LVal - 1) (LVal >= Nnz) (Nnz is the number of nonzero elements of the matrix)
Values of nonzero elements of the matrix A. |
| [in] | Ptr() | Array Ptr(LPtr - 1) (LPtr >= N + 1)
Column pointers (if CSC) or row pointers (if CSR) of the matrix A. |
| [in] | Ind() | Array Ind(LInd - 1) (LInd >= Nnz)
Row indices (if CSC) or column indices (if CSR) of the matrix A. |
| [in,out] | B() | Array B(LB1 - 1, LB2 - 1) (LB1 >= N, LB2 >= Nrhs) (2D array) or B(LB - 1) (LB >= N, Nrhs = 1) (1D array)
[in] N x Nrhs right hand side matrix B.
[out] The solution matrix X. |
| [out] | Rcond | Estimated reciprocal of the condition number of the matrix A. |
| [out] | Info | (Optional)
= 0: Successful exit.
< 0: The (-Info)-th argument is invalid.
= -10000: Unrecoverble error occured in SuperLU routine.
= i > 0 and <= N: U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, so the solution could not be computed.
= i > N: Memory allocation failure occurred. i - N is the number of bytes allocated. |
| [in] | Format | (Optional)
Sparse matrix format. (default = 0)
= 0: CSR format.
= 1: CSC format. |
| [in] | Base | (Optional)
Indexing of Rowptr() and Colind().
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1.
(default: Assumes 1 if Ptr(0) = 1, otherwise 0) |
| [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) |
| [in] | ColPerm | (Optional)
Specifies the type of column ordering to reduce fill-in.
= "A": Approximate minimum degree (AMD) ordering.
= "N": Natural ordering (No ordering) (Pc = I).
= "M": Multiple minimum degree (MMD) ordering on A^T*A.
= "P": Multiple minimum degree (MMD) ordering on A^T + A.
(default = "A") |
| [in] | Thresh | (Optional)
Specifies the threshold used for a diagonal entry to be an acceptable pivot (0 <= Thresh <= 1). (default = 1) |
| [in] | SymMode | (Optional)
Specifies whether to use symmetric mode. Symmetric mode gives preference to diagonal pivots, and uses an (A^T + A)-based column permutation algorithm.
= "N": Do not use symmetric mode.
= "S": Use symmetric mode.
(default = "N") |
- Reference
- SuperLU
- Example Program
- Solve the system of linear equations Ax = B and estimate the reciprocal of the condition number (RCond) of A, where
( 0.2 -0.11 -0.93 ) ( -0.3727 )
A = ( -0.32 0.81 0.37 ), B = ( 0.4319 )
( -0.8 -0.92 -0.29 ) ( -1.4247 )
Sub Ex_Dgssv()
Const N = 3, Nnz = N * N
Dim A(Nnz - 1) As Double, Ia(N) As Long, Ja(Nnz - 1) As Long
Dim B(N - 1) As Double
Dim RCond As Double, Info As Long
A(0) = 0.2: A(1) = -0.11: A(2) = -0.93: A(3) = -0.32: A(4) = 0.81: A(5) = 0.37: A(6) = -0.8: A(7) = -0.92: A(8) = -0.29
Ia(0) = 0: Ia(1) = 3: Ia(2) = 6: Ia(3) = 9
Ja(0) = 0: Ja(1) = 1: Ja(2) = 2: Ja(3) = 0: Ja(4) = 1: Ja(5) = 2: Ja(6) = 0: Ja(7) = 1: Ja(8) = 2
B(0) = -0.3727: B(1) = 0.4319: B(2) = -1.4247
Call Dgssv(N, A(), Ia(), Ja(), B(), RCond, Info)
Debug.Print "X =", B(0), B(1), B(2)
Debug.Print "RCond = " + CStr(RCond) + ", Info = " + CStr(Info)
End Sub
Sub Dgssv(N As Long, Val() As Double, Ptr() As Long, Ind() As Long, B() As Double, RCond As Double, Optional Info As Long, Optional Format As Long=0, Optional Base As Long=-1, Optional Nrhs As Long=1, Optional ColPerm As String="A", Optional Thresh As Double=1, Optional SymMode As String="N") Solves the system of linear equations A*X = B (direct method) (sparse matrix) (SuperLU) (simple drive...
- Example Results
X = 0.86 0.64 0.51
RCond = 0.246230172077849, Info = 0
|