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
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
#include <iostream>
#include <flens/flens.cxx>

using namespace std;
using namespace flens;

typedef double   T;

int
main()
{
    typedef TpMatrix<PackedStorage<T, Upper> >  Matrix;
    typedef DenseVector<Array<T> >              Vector;

    typedef Matrix::IndexType                   IndexType;
    typedef DenseVector<Array<IndexType> >      IndexVector;

    const IndexType n = 4;

    ///
    /// The parameter define the dimensions (always a square matrix)
    ///

    Matrix         Ap(n);
    Vector         b(n), x(n);

    for (IndexType i = 1; i <= n; ++i)
        for (IndexType j = i; j <= n; ++j)
            Ap(i,j) = i + 2*j;

    b = 20,
       -33,
       -43,
        49;

    cout << "Ap = " << Ap << endl;
    cout << "b  = " << b << endl;

    ///
    /// Compute $x = A^T b$
    ///
    x = transpose(Ap)*b;

    cout << "x = " << x << endl;

    ///
    /// Solve $x = A^T b$
    ///
    blas::sv(Trans, Ap, x);

    cout << "b = " << b << endl;

    return 0;
}