# 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:
1. Phase 0: Definition of the (distributed) linear algebra objects;
2. Phase 1: Initializing Amesos;
3. Phase 2: Initializing the Factory;
4. Phase 3: Performing the factorization;
5. 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

1. You initialize the Factory, which is a function class (a class that contains methods only, no data):
```Amesos Factory;
```
2. You specify the solver you want to use:
```string SolverType = "Klu";
```
3. 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

• The symbolic factorization phase will only consider the matrix structure, but not its values:
```  ierr = Solver->SymbolicFactorization();
if (ierr > 0) cerr << "ERROR!" << endl;
```
Matrix values (but not structure) can change after this call.
• The numeric factorization will compute the L and U factors:
```  ierr = Solver->NumericFactorization();
if (ierr > 0) cerr << "ERROR!" << endl;
```

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