  # Chapter 12: Case Study: Two Sparse Least-Squares System Examples

Source Code:

Two application routines are constructed that lead to the solution of sparse linear systems of algebraic equations with size (M+N) by (M+N). The operations to build the matrices and solve the equations use the defined operations for sparse matrices and the provided utilities to build the data structures.

There are two executables which may be generated using the makefile.

• driverPiecewiseLinear uses set_precision.f90, sluInterop.f90, sortElements.f90, sparseAssign.f90, sparseOps.f90, sparseSort.f90, sparseTypes.f90, and sparseUtils.f90, fortran_double_call_SuperLU.c, and SuperLU v4.3 as a library.

Routine driverPiecewiseLinear fits a piecewise-linear, continuous function to sampled points of the quadratic function, t**2. The use of t**2 is for illustration only.

• driverAiryBVP uses the same components as driverPiecewiseLinear above.

This program uses piece-wise linear, continuous functions to solve a boundary value problem using finite elements. The problem is Airy's equation with values x(0)=1 and x(1)=1 and requires the solution of a linear system of size (2*n - 2) by (2*n - 2).

### Sample output from driverPiecewiseLinear

``` Data Fitting of y(t)=t**2, (0,1).
The number of breakpoints (N) and data points (M)       2000     14810

Relative Error (1) (Vector Norm)
with solution and computed residual = 1.97996E-13
The SuperLU factorization completed with N =     16810

The nonzero values of L, U and their sum =    126191    120569    246760

Memory Usage (KBytes) for LU step   =   2.528608E+03
Total Usage  (KBytes) for all terms =   6.361288E+03

Repeated Data Fitting of y(t)=t**2, (0,1) - No Factorization -.
The number of breakpoints (N) and data points (M)       2000     14810

Relative Error (2) (Vector Norm)
with solution and computed residual = 1.97996E-13
```

### Sample output from driverAiryBVP

``` x(2) =   0.1000E+01 x(n-1) =   0.1000E+01
With n function values =   10001
Maximum Least Squares Residual Value =  4.9998D-09
```
 Search this site: Search book catalog: Search journals: Search proceedings: Search news: