1590 MatSolve Example

Bagaev Dmitri edited this page Nov 29, 2016 · 4 revisions

Solve the Matrix stored in mtx format

The code for this example is located in Examples/MatSolve


This example solves the linear system using different solvers.


This example may run in both serial and parallel modes with NP processes.

The code loads the matrix and right-hand side from files. If right-hand side is omitted, the artificial rhs=(1,1,...,1) is used. The specific solver is defined by user. User may also provide options file to alter default solver options.


Usage: ./MatSolve -m "matrix.mtx" [arguments]
  • Available arguments
    • Required
      • -m, --matrix, specifies path to the matrix file, e.g. "/tmp/A.mtx"
    • Optional
      • -b, --bvector, specifies path to the rhs file, e.g. "/tmp/b.rhs"
      • -x, --xvector, specifies path to the solution
      • -p, --parameters, specifies path to the database file, see Examples/MatSolve/database.xml as example;
      • -t, --type, specifies solver type, "inner_ilu2" by default
      • -h, --help, prints help message

Running example

You can generate matrices using FVDiscr example. The following line uses matrix /tmp/A.mtx and right-hand side /tmp/b.rhs from FVDiscr example.

$ cd Examples/MatSolve
$ mpirun -np 4 ./MatSolve -m /tmp/A.mtx -b /tmp/b.rhs 
load matrix: 0.346156
load vector: 0.0542159
preconditioner: 0.516358
solver: 0.0345631.37095e-06 | 0
||Ax-b|| 1.37095e-06 ||b|| 2.14884 ||Ax-b||/||b|| 6.37997e-07
norms: 0.00276518
4 processors solved in 0.95183 secs with 4 iterations to 1.37095e-06 norm matrix "/tmp/A.mtx" vector "/tmp/b.rhs" true residual ||Ax-b||/||b|| 6.37997e-07
reason: converged due to relative tolerance
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.