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
#include <cxxstd/iostream.h>
#include <flens/flens.cxx>

using namespace std;
using namespace flens;

int
main()
{
    GeMatrix<FullStorage<double> >   AB(44+3);
    DenseVector<Array<int> >         piv(4);

    Underscore<int> _;

    auto A = AB(_,_(1,4));
    auto B = AB(_,_(5,7));

    A =  2,   3,  -1,   0,
        -6,  -5,   0,   2,
         2,  -5,   6,  -6,
         4,   6,   2,  -3;

    fillRandom(B);

    cout << "(A,B) = " << AB << endl;

///
/// *A pripori* compute the triangular factorization $PLU = (A,B)$ using the
/// __FLENS-LAPACK__ function `lapack::trf`.
///
    lapack::trf(AB, piv);

///
/// Solve $U X = B$ using __FLENS-BLAS__ function `blas::sv.  Matrix $B$ gets
/// overwritten with the solution $X$.
///
    blas::sm(Left, NoTrans, 1.0, A.upper(), B);

    cout << "X = " << B << endl;
}

///
///     :links: FLENS-LAPACK -> doc:flens/lapack/lapack
///             FLENS-BLAS   -> doc:flens/blas/blas
///