NAG Library Routine Document
F01BSF
1 Purpose
F01BSF factorizes a real sparse matrix using the pivotal sequence previously obtained by
F01BRF when a matrix of the same sparsity pattern was factorized.
2 Specification
SUBROUTINE F01BSF ( 
N, NZ, A, LICN, IVECT, JVECT, ICN, IKEEP, IW, W, GROW, ETA, RPMIN, ABORT, IDISP, IFAIL) 
INTEGER 
N, NZ, LICN, IVECT(NZ), JVECT(NZ), ICN(LICN), IKEEP(5*N), IW(5*N), IDISP(2), IFAIL 
REAL (KIND=nag_wp) 
A(LICN), W(N), ETA, RPMIN 
LOGICAL 
GROW, ABORT 

3 Description
F01BSF accepts as input a real sparse matrix of the same sparsity pattern as a matrix previously factorized by a call of
F01BRF. It first applies to the matrix the same permutations as were used by
F01BRF, both for permutation to block triangular form and for pivoting, and then performs Gaussian elimination to obtain the
$LU$ factorization of the diagonal blocks.
Extensive data checks are made; duplicated nonzeros can be accumulated.
The factorization is intended to be used by
F04AXF to solve sparse systems of linear equations
$Ax=b$ or
${A}^{\mathrm{T}}x=b$.
F01BSF is much faster than
F01BRF and in some applications it is expected that there will be many calls of F01BSF for each call of
F01BRF.
The method is fully described in
Duff (1977).
A more recent algorithm for the same calculation is provided by
F11MEF.
4 References
Duff I S (1977) MA28 – a set of Fortran subroutines for sparse unsymmetric linear equations AERE Report R8730 HMSO
5 Parameters
 1: N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint:
${\mathbf{N}}>0$.
 2: NZ – INTEGERInput
On entry: the number of nonzero elements in the matrix $A$.
Constraint:
${\mathbf{NZ}}>0$.
 3: A(LICN) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{A}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NZ}}$, must contain the nonzero elements of the sparse matrix $A$. They can be in any order since F01BSF will reorder them.
On exit: the nonzero elements in the
$LU$ factorization. The array must
not be changed by you between a call of F01BSF and a call of
F04AXF.
 4: LICN – INTEGERInput
On entry: the dimension of the arrays
A and
ICN as declared in the (sub)program from which F01BSF is called. It should have the same value as it had for
F01BRF.
Constraint:
${\mathbf{LICN}}\ge {\mathbf{NZ}}$.
 5: IVECT(NZ) – INTEGER arrayInput
 6: JVECT(NZ) – INTEGER arrayInput
On entry: ${\mathbf{IVECT}}\left(\mathit{i}\right)$ and ${\mathbf{JVECT}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NZ}}$, must contain the row index and the column index respectively of the nonzero element stored in ${\mathbf{A}}\left(i\right)$.
 7: ICN(LICN) – INTEGER arrayInput
ICN contains, on entry, the same information as output by
F01BRF. It must not be changed by you between a call of F01BSF and a call of
F04AXF.
ICN is used as internal workspace prior to being restored on exit and hence is unchanged.
 8: IKEEP($5\times {\mathbf{N}}$) – INTEGER arrayCommunication Array
On entry: the same indexing information about the factorization as output in
IKEEP by
F01BRF.
You must
not change
IKEEP between a call of F01BSF and subsequent calls to
F04AXF.
 9: IW($5\times {\mathbf{N}}$) – INTEGER arrayWorkspace
 10: W(N) – REAL (KIND=nag_wp) arrayOutput
On exit: if
${\mathbf{GROW}}=\mathrm{.TRUE.}$,
${\mathbf{W}}\left(1\right)$ contains an estimate (an upper bound) of the increase in size of elements encountered during the factorization (see
GROW); the rest of the array is used as workspace.
If ${\mathbf{GROW}}=\mathrm{.FALSE.}$, the array is not used.
 11: GROW – LOGICALInput
On entry: if
${\mathbf{GROW}}=\mathrm{.TRUE.}$, then on exit
${\mathbf{W}}\left(1\right)$ contains an estimate (an upper bound) of the increase in size of elements encountered during the factorization. If the matrix is wellscaled (see
Section 8), then a high value for
${\mathbf{W}}\left(1\right)$ indicates that the
$LU$ factorization may be inaccurate and you should be wary of the results and perhaps increase the parameter
PIVOT for subsequent runs (see
Section 7).
 12: ETA – REAL (KIND=nag_wp)Input
On entry: the relative pivot threshold below which an error diagnostic is provoked and
IFAIL is set to
${\mathbf{IFAIL}}={\mathbf{7}}$. If
ETA is greater than
$1.0$, then no check on pivot size is made.
Suggested value:
${\mathbf{ETA}}={10}^{4}$.
 13: RPMIN – REAL (KIND=nag_wp)Output
On exit: if
ETA is less than
$1.0$, then
RPMIN gives the smallest ratio of the pivot to the largest element in the row of the corresponding upper triangular factor thus monitoring the stability of the factorization. If
RPMIN is very small it may be advisable to perform a new factorization using
F01BRF.
 14: ABORT – LOGICALInput
On entry: if
${\mathbf{ABORT}}=\mathrm{.TRUE.}$, F01BSF exits immediately (with
${\mathbf{IFAIL}}={\mathbf{8}}$) if it finds duplicate elements in the input matrix.
If ${\mathbf{ABORT}}=\mathrm{.FALSE.}$, F01BSF proceeds using a value equal to the sum of the duplicate elements.
In either case details of each duplicate element are output on the current advisory message unit (see
X04ABF), unless suppressed by the value of
IFAIL on entry.
Suggested value:
${\mathbf{ABORT}}=\mathrm{.TRUE.}$.
 15: IDISP($2$) – INTEGER arrayCommunication Array
On entry:
${\mathbf{IDISP}}\left(1\right)$ and
${\mathbf{IDISP}}\left(2\right)$ must be as output in
IDISP by the previous call of
F01BRF.
 16: IFAIL – INTEGERInput/Output

For this routine, the normal use of
IFAIL is extended to control the printing of error and warning messages as well as specifying hard or soft failure (see
Section 3.3 in the Essential Introduction).
On entry:
IFAIL must be set to a value with the decimal expansion
$\mathit{cba}$, where each of the decimal digits
$c$,
$b$ and
$a$ must have a value of
$0$ or
$1$.
$a=0$ 
specifies hard failure, otherwise soft failure; 
$b=0$ 
suppresses error messages, otherwise error messages will be printed (see Section 6); 
$c=0$ 
suppresses warning messages, otherwise warning messages will be printed (see Section 6). 
The recommended value for inexperienced users is $110$ (i.e., hard failure with all messages printed).
On exit:
${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
 ${\mathbf{IFAIL}}=1$
On entry,  ${\mathbf{N}}\le 0$. 
 ${\mathbf{IFAIL}}=2$
On entry,  ${\mathbf{NZ}}\le 0$. 
 ${\mathbf{IFAIL}}=3$
On entry,  ${\mathbf{LICN}}<{\mathbf{NZ}}$. 
 ${\mathbf{IFAIL}}=4$
On entry, an element of the input matrix has a row or column index (i.e., an element of
IVECT or
JVECT) outside the range
$1$ to
N.
 ${\mathbf{IFAIL}}=5$
The input matrix is incompatible with the matrix factorized by the previous call of
F01BRF (see
Section 8).
 ${\mathbf{IFAIL}}=6$
The input matrix is numerically singular.
 ${\mathbf{IFAIL}}=7$
A very small pivot has been detected (see
Section 5,
ETA). The factorization has been completed but is potentially unstable.
 ${\mathbf{IFAIL}}=8$
Duplicate elements have been found in the input matrix and the factorization has been abandoned (${\mathbf{ABORT}}=\mathrm{.TRUE.}$ on entry).
7 Accuracy
The factorization obtained is exact for a perturbed matrix whose $\left(i,j\right)$th element differs from ${a}_{ij}$ by less than $3\epsilon \rho {m}_{ij}$ where $\epsilon $ is the machine precision, $\rho $ is the growth value returned in ${\mathbf{W}}\left(1\right)$ if ${\mathbf{GROW}}=\mathrm{.TRUE.}$, and ${m}_{ij}$ the number of Gaussian elimination operations applied to element $\left(i,j\right)$.
If
$\rho ={\mathbf{W}}\left(1\right)$ is very large or
RPMIN is very small, then a fresh call of
F01BRF is recommended.
If you have a sequence of problems with the same sparsity pattern then F01BSF is recommended after
F01BRF has been called for one such problem. It is typically
$4$ to
$7$ times faster but is potentially unstable since the previous pivotal sequence is used. Further details on timing are given in the document for
F01BRF.
If growth estimation is performed (${\mathbf{GROW}}=\mathrm{.TRUE.}$), then the time increases by between $5\%$ and $10\%$. Pivot size monitoring (${\mathbf{ETA}}\le 1.0$) involves a similar overhead.
We normally expect this routine to be entered with a matrix having the same pattern of nonzeros as was earlier presented to
F01BRF. However there is no record of this pattern, but rather a record of the pattern including all fillins. Therefore we permit additional nonzeros in positions corresponding to fillins.
If singular matrices are being treated then it is also required that the present matrix be sufficiently like the previous one for the same permutations to be suitable for factorization with the same set of zero pivots.
9 Example
This example factorizes the real sparse matrices
and
This example program simply prints the values of
${\mathbf{W}}\left(1\right)$ and
RPMIN returned by F01BSF. Normally the calls of
F01BRF and F01BSF would be followed by calls of
F04AXF.
9.1 Program Text
Program Text (f01bsfe.f90)
9.2 Program Data
Program Data (f01bsfe.d)
9.3 Program Results
Program Results (f01bsfe.r)