# A Quick Introduction to Amesos

### Marzio Sala

###
Use left and right arrows to move through the presentation, and when you are
finished click "Page
Back" to go back to the previous page. The Amesos web page
is here.

# What We Will Do Here

This is a very quick introduction to the usage of Amesos. We will show the
basic commands that are required to solve a linear system. The presentation
is organized as follows:

- Phase 0: Definition of the (distributed) linear algebra objects;
- Phase 1: Initializing Amesos;
- Phase 2: Initializing the Factory;
- Phase 3: Performing the factorization;
- Phase 4: Solving the linear system.

# Phase 0: Linear Algebra Objects

We suppose that:

- your matrix,
`A`, is squared and stored using an
`Epetra_RowMatrix`-derived class (for example, an
`Epetra_CrsMatrix`);
- your solution,
`LHS`, and right-hand side, `RHS`, are stored
as `Epetra_Vector` or `Epetra_MultiVector`; and
- you want to use a direct solver for the linear system solution.

# Phase 0: Linear Algebra Objects (cont'd)

This means that your code contains something like:

Epetra_RowMatrix* A;
Epetra_MultiVector* LHS;
Epetra_MultiVector* RHS;
Epetra_LinearProblem Problem(A, LHS, RHS);

We will not show here how to define

`A`,

`LHS` and

`RHS`;
check the

Trilinos
tutorial if you need help on this subject. We also suppose that your
code includes the basic Amesos header file:

#include "Amesos.h"

# Phase 1: Initializing Amesos

First, you have to initialize the

**Amesos** solver.
This is done by declaring a pointer to an

`Amesos_BaseSolver` object:

Amesos_BaseSolver* Solver;

Note that

`Amesos_BaseSolver` is a pure virtual class.

# Phase 2: Initializing the Factory

- You initialize the
`Factory`, which is a function class (a
class that contains methods only, no data):
Amesos Factory;

- You specify the solver you want to use:
string SolverType = "Klu";

- and finally you can declare your
`Solver`:
Solver = Factory.Create(SolverType, Problem);
if (Solver == 0) {
cerr << "Specified solver is not available" << endl;
}

# Phase 2: Initializing the Factory (cont'd)

Possible choices for

`SolverType` are:

`Lapack`, `Klu`, `Umfpack`, `Taucs`,
`Superlu` for serial solvers; and
`Superludist`, `Mumps`, `Dscpack`, `Pardiso` and `Paraklete` for parallel
solvers.

Only the LAPACK and KLU interfaces are enabled by default. KLU and Paraklete
are distributed within Amesos; all the other solvers must be downloaded and
installed before configuring Amesos.

# Phase 3: Perform the Factorization

# Phase 4: Solve the Linear System

Solving simply requires

Solver->Solve();

and nothing more! To test another solver, simply pass a different

`SolverType` to the

`Factory`.
Certain phases can be customized using a parameter list. For example, for
verbose output, do this before calling

`SymbolicFactorization`:

Teuchos::ParameterList List;
List.set("PrintTiming", true);
List.set("PrintStatus", true);
Solver->SetParameters(List);

# End of the show!

This was a rapid overview of Amesos. Please check the web pages, the examples
contained in the distribution, and the manuals for more details.
Feel free to contact the

developers if you need help!