Difference between revisions of "LinAlgebraPacks"

From SourceWiki
Jump to navigation Jump to search
Line 72: Line 72:
 
</pre>
 
</pre>
  
 +
Solving a 2D laplacian:
 +
 +
<pre>
 +
./simple-laplace.exe
 +
</pre>
 +
 +
More flexible:
 +
 +
<pre>
 +
./mxm-laplace.exe
 +
</pre>
  
 
=PetSc: Iterative solutions and sparse matrices=
 
=PetSc: Iterative solutions and sparse matrices=

Revision as of 12:30, 7 February 2011

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

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

For example, consider the following system:

[math]\displaystyle{ \begin{alignat}{7} x &&\; + \;&& 3y &&\; - \;&& 2z &&\; = \;&& 5 & \\ 3x &&\; + \;&& 5y &&\; + \;&& 6z &&\; = \;&& 7 & \\ 2x &&\; + \;&& 4y &&\; + \;&& 3z &&\; = \;&& 8 & \end{alignat} }[/math]

The following computation shows Gauss-Jordan elimination applied to the matrix above:

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

To solve this using LAPACK:

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

Solving a 2D laplacian:

./simple-laplace.exe

More flexible:

./mxm-laplace.exe

PetSc: Iterative solutions and sparse matrices

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

See examples included in PetSc distribution.

PLASMA: For Multicore Architectures

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

MAGMA: To include GPUs in Heterogeneous Systems

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