# WATHEN Assemble, Factor, Solve a Finite Element System

WATHEN is a Python 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:

JACOBI, a Python library which implements the Jacobi iteration for solving symmetric positive definite (SPD) systems of linear equations.

R8LIB, a Python library which contains many utility routines using double precision real (R8) arithmetic.

### 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.

### Source Code:

• cg_csc.py, solves A*x=b using the conjugate gradient method, with A a positive definite symmetric matrix stored in Python's Compressed Sparse Column (CSC) format.
• cg_ge.py, solves A*x=b using the conjugate gradient method, with A a positive definite symmetric matrix using general (GE) storage.
• cg_st.py, solves A*x=b using the conjugate gradient method, with A a positive definite symmetric matrix using sparse triplet (ST) storage.
• mv_st.py, multiplies a sparse triplet matrix times a vector.
• nonzeros.py, counts nonzeros in a matrix.
• r8_uniform_01.py, returns a unit random R8.
• r8mat_uniform_01.py, returns a unit random R8MAT.
• r8vec_print.py, prints an R8VEC.
• r8vec_uniform_01.py, returns a unit random R8VEC.
• st_to_ge.py, converts a sparse triplet (ST) matrix to general (GE) format.
• timestamp.py, prints the YMDHMS date as a timestamp.
• wathen_bandwidth.py, returns the bandwidth of the Wathen matrix.
• wathen_csc.py, sets up the Wathen matrix using Python's Compressed Sparse Column (CSC) format.
• wathen_ge.py, sets up the Wathen matrix using general (GE) storage.
• wathen_order.py, returns the number of unknowns associated with a given Wathen matrix.
• wathen_st.py, sets up the Wathen matrix using sparse triplet storage.
• wathen_st_size.py, returns the size of the Wathen matrix when using sparse triplet storage.

### Examples and Tests:

You can go up one level to the PYTHON source codes.