# IMSL_SP_LUFAC

The IMSL_SP_LUFAC function computes an LU factorization of a sparse matrix stored in either coordinate format or CSC format. Using keywords, any of several related computations can be performed.

Note: This routine requires an IDL Analyst license. For more information, contact your Exelis VIS sales or technical support representative.

The IMSL_SP_LUFAC function computes an LU factorization of A using the improved generalized symmetric Markowitz pivoting scheme.

If a sequence of systems Ax = b are to be solved where A is unchanged, it is usually more efficient to compute the factorization once and perform multiple forward and back solves with the various right-hand sides. In this case, the factor L is explicitly stored and a record of all rows as well as column interchanges is made. The solve step then solves the two triangular systems Ly = b and Ux = y. In this case, first call IMSL_SP_LUFAC to compute the factorization, then use the keyword FACTOR_COORD with the IMSL_SP_LUSOL function.

If the solution to ATx = b is required, specify the keyword TRANSPOSE. This keyword only alters the forward elimination and back substitution so that the operations UTy = b and LTx = y are performed to obtain the solution. So, with one call to IMSL_SP_LUFAC to produce the factorization, solutions to both Ax = b and ATx = b can be obtained.

The keyword CONDITION is used to calculate and return an estimation of the L1 condition number of A. The algorithm used is due to Higham. Specifying CONDITION causes a complete L to be computed and stored, even if a one-off problem is being solved. This is due to the fact that Higham’s method requires solution to problems of the form Az = r and ATz = r.

The default pivoting strategy is symmetric Markowitz (PIVOTING = 3). If a row or column oriented problem is encountered, there may be some reduction in fill-in by selecting either PIVOTING = 1 for row Markowitz, or PIVOTING = 2 for column Markowitz. The Markowitz strategy will search a pre-elected number of rows or columns for pivot candidates. The default number is three, but this can be changed by using the keyword N_SEARCH_ROWS.

The keyword TOL_DROP can be used to set a tolerance which can reduce fill-in. This works by preventing any new fill element which has magnitude less than the specified drop tolerance from being added to the factorization. Since this can introduce substantial error into the factorization, it is recommended that the keyword ITER_REFINE be used to recover more accuracy in the final solution. The trade-off is between space savings from the drop tolerance and the extra time needed in repeated solve steps needed for refinement.

The IMSL_SP_LUFAC function provides the option of switching to a dense factorization method at some point during the decomposition. This option is enabled by specifying the keywords HYBRID_DENSITY and HYBRID_ORDER. HYBRID_DENSITY specifies a minimum density for the active submatrix before a format switch will occur. A density of 1.0 indicates complete fill-in. HYBRID_ORDER places an upper bound of the order of the active submatrix which will be converted to dense format. This is used to prevent a switch from occurring too early, possibly when the O(n3) nature of the dense factorization will cause performance degradation. Note that this option can significantly increase heap storage requirements.

## Example

Consider the following matrix:

This example factors A using IMSL_SP_LUFAC, and computes solutions to the systems Ax1 = b1 and Ax2 = b2 using the computed factor as input to IMSL_SP_LUSOL.

A = replicate(imsl_f_sp_elem, 15)

; Define the sparse matrix A using coordinate storage format.

a(*).row = [0, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5]

a(*).col = [0, 1, 2, 3, 2, 0, 3, 4, 0, 3, 4, 5, 0, 1, 5]

a(*).val = [10, 10, -3, -1, 15, -2, 10, -1, -1, -5, $

1, -3, -1, -2, 6]

b1 = [10, 7, 45, 33, -34, 31]

b2 = [50, 40, 225, 130, -85, 5]

; Define the right-hand sides.

factor = IMSL_SP_LUFAC(a, 6)

; Compute the LU factorization.

x1 = IMSL_SP_LUSOL(b1, factor_coord = factor)

; Call IMSL_SP_LUSOL with factor and b1, then print result

; and the sum of the residuals.

PM, x1

1.0000000

2.0000000

3.0000000

4.0000000

5.0000000

6.0000000

PM, TOTAL(ABS(IMSL_SP_MVMUL(6, 6, a, x1) - b1))

8.8817842e-16

x2 = IMSL_SP_LUSOL(b2, factor_coord = factor)

; Call IMSL_SP_LUSOL with factor and b2, then print out

; result and the sum of the residuals.

PM, x2

5.0000000

10.000000

15.000000

15.000000

10.000000

5.0000000

PM, TOTAL(ABS(IMSL_SP_MVMUL(6, 6, a, x2) - b2))

1.4210855e-14

## Syntax

Result =IMSL_SP_LUFAC(a, n_rows [, CONDITION=variable] [, /CSC_COL] [, /CSC_ROW] [, /CSC_VAL] [, GWTH_FACTOR=variable] [, GWTH_LIM=value] [, /HYBRID_DENSITY] [, /HYBRID_ORDER] [,ITER_REFINE=value] [, MEMORY_BLOCK=value] [, N_NONZEROS=variable] [, N_SEARCH_ROWS=value] [, PIVOTING=value] [, SMALLEST_PVT=variable] [, STABILITY=value] [, TOL_DROP=value] [, TRANSPOSE=value])

## Return Value

Structure containing the LU factorization of A.

## Arguments

### a

Sparse matrix stored as an array of structures containing the coefficient matrix A(i,j). See “Sparse Matrices: Direct Methods” and its related sections for a description of structures used for sparse matrices.

### n_rows

The number of rows in a.

## Keywords

### CONDITION

Named variable into which an estimate of the L1 condition number is stored.

### CSC_COL

Accept the coefficient matrix in compressed sparse column (CSC) format. See “Sparse Coordinate Storage Format” for a discussion of this storage scheme. The keywords CSC_COL, CSC_ROW, and CSC_VAL must be used together.

### CSC_ROW

Accept the coefficient matrix in compressed sparse column (CSC) format. See “Sparse Coordinate Storage Format” for a discussion of this storage scheme. The keywords CSC_COL, CSC_ROW, and CSC_VAL must be used together.

### CSC_VAL

Accept the coefficient matrix in compressed sparse column (CSC) format. See “Sparse Coordinate Storage Format” for a discussion of this storage scheme. The keywords CSC_COL, CSC_ROW, and CSC_VAL must be used together.

### GWTH_FACTOR

Named variable into which the largest element in absolute value at any stage of the Gaussian elimination divided by the largest element in absolute value in A is stored.

### GWTH_LIM

The computation stops if the growth factor exceeds GWTH_LIMIT. Default is 1.0e16.

### HYBRID_DENSITY

Enable the function to switch to a dense factorization method when the density of the active submatrix reaches 0.0 ≤ HYBRID_DENSITY ≤ 1.0 and the order of the active submatrix is less than or equal to HYBRID_ORDER. The keywords HYBRID_DENSITY and HYBRID_ORDER must be used together.

### HYBRID_ORDER

Enable the function to switch to a dense factorization method when the density of the active submatrix reaches 0.0 ≤ HYBRID_DENSITY ≤ 1.0 and the order of the active submatrix is less than or equal to HYBRID_ORDER. The keywords HYBRID_DENSITY and HYBRID_ORDER must be used together.

### ITER_REFINE

If present and nonzero, iterative refinement will be applied.

### MEMORY_BLOCK

Supply the number of non-zeros which will be added to the factor if current allocations are inadequate. Default: MEMORY_BLOCK = N_ELEMENTS(a)

### N_NONZEROES

Named variable into which the total number of non-zeros in the factor is stored.

### N_SEARCH_ROWS

The number of rows which have the least number of non-zero elements that will be searched for a pivot element. Default: N_SEARCH_ROWS = 3.

### PIVOTING

Scalar value specifying the pivoting method to use. For Row Markowitz, set PIVOTING to 1; for Column Markowitz, set PIVOTING to 2; and for Symmetric Markowitz, set PIVOTING to 3. Default: PIVOTING = 3.

### SMALLEST_PVT

Named variable into which the value of the pivot element of smallest magnitude that occurred during the factorization is stored.

### STABILITY

The absolute value of the pivot element must be bigger than the largest element in absolute value in its row divided by STABILITY. Default: STABILITY = 10.0.

### TOL_DROP

Possible fill-in is checked against this tolerance. If the absolute value of the new element is less than TOL_DROP, it will be discarded. Default: TOL_DROP = 0.0.

### TRANSPOSE

If present and nonzero, ATx = b is solved.

## Version History

6.4 | Introduced

## See Also

IMSL_SP_LUSOL