# WATHEN Assemble, Factor, Solve a Finite Element System

WATHEN is a C++ library which compares storage schemes (full, banded, sparse triplet, sparse) and solution strategies (A\x, Linpack, conjugate gradient (CG)) for linear systems involving the Wathen matrix, which can arise when solving a problem using the finite element method (FEM).

The Wathen matrix is a typical example of a matrix that arises during finite element computations. The parameters NX and NY specify how many elements are to be set up in the X and Y directions. The number of variables N is then

```        N = 3 NX NY + 2 NX + 2 NY + 1
```
and the full linear system will require N * N storage for the matrix.

However, the matrix is sparse, and a banded or sparse storage scheme can be used to save storage. However, even if storage is saved, a revised program may eat up too much time because MATLAB's sparse storage scheme is not efficiently used by inserting nonzero elements one at a time. Moreover, if banded storage is employed, the user must provide a suitable fast solver. Simply "translating" a banded solver from another language will probably not provide an efficient routine.

This library looks at how the complexity of the problem grows with increasing NX and NY; how the computing time increases; how the various full, banded and sparse approaches perform.

### Languages:

WATHEN is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

### Related Data and Programs:

CG, a C++ library which implements a simple version of the conjugate gradient (CG) method for solving a system of linear equations of the form A*x=b, suitable for situations in which the matrix A is positive definite (only real, positive eigenvalues) and symmetric.

LINPACK_D, a C++ library which factors and solves linear systems using double precision real arithmetic, by Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart.

SPARSE_DISPLAY, a C++ library which can read information defining a matrix of numbers and display the sparsity pattern or location of the nonzero elements using gnuplot. This operation is already available in the built-in MATLAB "spy" command.

TEST_MAT, a C++ library which defines test matrices for which some of the determinant, eigenvalues, inverse, null vectors, P*L*U factorization or linear system solution are already known, including the Vandermonde and Wathen matrix.

### Reference:

1. Nicholas Higham,
Algorithm 694: A Collection of Test Matrices in MATLAB,
ACM Transactions on Mathematical Software,
Volume 17, Number 3, September 1991, pages 289-305.
2. Andrew Wathen,
Realistic eigenvalue bounds for the Galerkin mass matrix,
IMA Journal of Numerical Analysis,
Volume 7, Number 4, October 1987, pages 449-457.

### List of Routines:

• BANDWIDTH returns the bandwidth of a matrix.
• CG_FULL uses the conjugate gradient method for a full storage matrix.
• CG_ST uses the conjugate gradient method for a sparse triplet storage matrix.
• DAXPY computes constant times a vector plus a vector.
• DDOT forms the dot product of two vectors.
• DGBFA factors a real band matrix by elimination.
• DGBSL solves a real banded system factored by DGBCO or DGBFA.
• DGEFA factors a real general matrix.
• DGESL solves a real general linear system A * X = B.
• DSCAL scales a vector by a constant.
• IDAMAX indexes the array element of maximum absolute value.
• NONZEROS counts the nonzeros in a matrix.
• R8_UNIFORM_01 returns a unit pseudorandom R8.
• R8GE_CG uses the conjugate gradient method on an R8GE system.
• R8GE_MXV multiplies an R8GE matrix by an R8VEC.
• R8MAT_UNIFORM_01 fills an R8MAT with unit pseudorandom numbers.
• R8VEC_PRINT prints an R8VEC.
• R8VEC_UNIFORM_01 returns a unit pseudorandom R8VEC.
• ST_MV multiplies a sparse triple matrix times a vector.
• TIMESTAMP prints the current YMDHMS date as a time stamp.
• WATHEN_BANDWIDTH returns the bandwidth of the WATHEN matrix.
• WATHEN_BANDED returns the Wathen matrix, using banded storage.
• WATHEN_FULL returns the Wathen matrix, using full storage.
• WATHEN_ORDER returns the order of the WATHEN matrix.
• WATHEN_ST: Wathen matrix stored in sparse triplet format.
• WATHEN_ST_SIZE: Size of Wathen matrix stored in sparse triplet format.

You can go up one level to the C++ source codes.

Last revised on 08 June 2014.