The complete code that implement the LinearSolver
interface for the UMFPACK solver is in solver_umfpack.cpp including the declaration of the class UMFPACK. This may look unusual but the reason is quite simple. The declaration of the class UMFPACK is used only to compile the code of the class and it will be never accessed from the application code directly. The application will work exclusively with solvers.h.
UMFPACK is a solver that is designed for unsymmetric matrices. If the matrix in question is symmetric, UMFPACK still can be used but the matrix should be given in the full storage.
The code starts with a declaration of structure
struct umfpack_matrix
{
long n;
long nz;
vector<UF_long> Ap; //colptr
vector<UF_long> Ai; //rowind
vector<double> Ax; //value.d
};
to support a UMFPACK matrix and the handle to a matrix from setMatrix
will give us a pointer to this structure. Well, the function returns void*
but it will be interpreted as umfpack_matrix*
. The class UMFPACK is derived from LinearSolver
class UMFPACK : public LinearSolver
{
vector<double> control;
vector<double> info;
bool verbose;
public:
...
The class has a couple data members to keep internal solver information. The implementation of functions is relatively straightforward and follows the UMFPACK documentations.
The last function is a bridge to the external world:
LinearSolver* make_UMFPACK()
{
return new UMFPACK;
}
and this function will be employed within LinearSolver::create
.
Previous
Introduction
Class Matrix
Class SparseMatrix
Sample code in C++ to run TAUCS
Sample code in C++ to run MUMPS
Class LinearSolver
Next
Class TAUCS
Class MUMPS and PARDISO
Gluing all together: LinearSolver::create
Sample driver to run a sparse solver
RSS