LinAlgebraPacks

Packages for Linear Algebra: Solving your system of equations using (optimised, bug-free) code that someone else has already written!

=Introduction=

svn co https://svn.ggy.bris.ac.uk/subversion-open/num-methods1 ./num-methods1

=LAPACK:direct solution of dense matrices=

http://www.netlib.org/lapack

For example, consider the following system:
 * $$\begin{alignat}{7}

x &&\; + \;&& 3y &&\; - \;&& 2z &&\; = \;&& 5 & \\ 3x &&\; + \;&& 5y &&\; + \;&& 6z &&\; = \;&& 7 & \\ 2x &&\; + \;&& 4y &&\; + \;&& 3z &&\; = \;&& 8 & \end{alignat}$$

(From http://en.wikipedia.org/wiki/System_of_linear_equations.)

The following computation shows Gauss-Jordan elimination applied to the matrix version of the above system of equations:
 * $$\left[\begin{array}{rrr|r}

1 & 3 & -2 & 5 \\ 3 & 5 & 6 & 7 \\ 2 & 4 & 3 & 8 \end{array}\right]$$$$\sim \left[\begin{array}{rrr|r} 1 & 3 & -2 & 5 \\ 0 & -4 & 12 & -8 \\ 2 & 4 & 3 & 8 \end{array}\right]$$$$\sim \left[\begin{array}{rrr|r} 1 & 3 & -2 & 5 \\ 0 & -4 & 12 & -8 \\ 0 & -2 & 7 & -2 \end{array}\right]$$$$\sim \left[\begin{array}{rrr|r} 1 & 3 & -2 & 5 \\ 0 & 1 & -3 & 2 \\ 0 & -2 & 7 & -2 \end{array}\right]$$$$\sim \left[\begin{array}{rrr|r} 1 & 3 & -2 & 5 \\ 0 & 1 & -3 & 2 \\ 0 & 0 & 1 & 2 \end{array}\right]$$$$\sim \left[\begin{array}{rrr|r} 1 & 3 & -2 & 5 \\ 0 & 1 & 0 & 8 \\ 0 & 0 & 1 & 2 \end{array}\right]$$$$\sim \left[\begin{array}{rrr|r} 1 & 3 & 0 & 9 \\ 0 & 1 & 0 & 8 \\ 0 & 0 & 1 & 2 \end{array}\right]$$$$\sim \left[\begin{array}{rrr|r} 1 & 0 & 0 & -15 \\ 0 & 1 & 0 & 8 \\ 0 & 0 & 1 & 2 \end{array}\right].$$

To solve this using LAPACK take a look inside dgesv-example.f90. First the declarations:

Next, we set up the matrix A:

And the vector B:

Once we have all that in place, all we need to do is call the solver routine:

Run the program to satisfy yourself that it works:

cd num-methods1/examples/example1 make ./dgesv-example.exe

Next, take a look at simple-laplace.f90. This program solves the 2D laplace equation for a 4x4 domain, as described on NumMethodsPDEs. This program only differs from the previous one in way in which we initialise the matrix A and vector b. To run the program type:

./simple-laplace.exe

The last in this series is mxm-laplace.f90. This program adds just a little more complexity, so that a 2D laplace equation can be solved on a more flexibly sized--mxm--square domain:

./mxm-laplace.exe

=Direct Solve using LU Decomposition=

=PetSc: Iterative solutions and sparse matrices=

http://www.mcs.anl.gov/petsc/petsc-as/

cd ../example3 make ./ex1f

For further examples see INSTALL_DIR/petsc-3.1-p1/src/ksp/ksp/examples/tutorials.

=PLASMA: For Multicore Architectures=

http://icl.cs.utk.edu/plasma/index.html

cd ../example4 make ./mxm-laplace-plasma.exe

For further examples, see e.g. INSTALL_DIR/plasma-installer_2.3.1/build/plasma_2.3.1.

=MAGMA: To include GPUs in Heterogeneous Systems=

http://icl.cs.utk.edu/magma/index.html