1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
#include <iostream>
#include <flens/examples/my_symatrix.h>
#include <flens/examples/cg.h>
#include <flens/flens.cxx>

using namespace flens;
using namespace std;

int
main()
{
    const int   n = 5;

    MySyMatrix  A;

    DenseVector<Array<double> > x(n), z(n), b(n);
    z = 1;
    b = A*z;

///
/// Solve $Ax=b$
///
    cg(A, b, x);
    cout << "x = " << x << endl;

///
/// Get the infinity norm of the error
///
    x -= z;
    cout << "max abs error = " << abs(x(blas::iamax(x))) << std::endl;
}