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

using namespace std;
using namespace flens;

typedef complex<double>   T;

int
main()
{
    typedef GeMatrix<FullStorage<T> >           Matrix;

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

    const Underscore<IndexType> _;

    ///
    ///  Set up the baby problem ...
    ///
    const IndexType m = 4,
                    n = 5;

    Matrix            Ab(m, n);
    IndexVector       piv(m);

    Ab = T(10), T( 1,-1), T(  2,20), T( 10),
         T(01), T( 12), T(-108), T(-11),
         T(0,-1), T(-11), T( 406), T(-2,-1);

    cout << "Ab = " << Ab << endl;

    ///
    /// Compute the $LU$ factorization with __lapack::trf__
    ///
    lapack::trf(Ab, piv);

    ///
    ///  Solve the system of linear equation $Ax =B$ using __blas::sm__
    ///
    const auto A = Ab(_,_(1,m));
    auto       B = Ab(_,_(m+1,n));

    blas::sm(Left, NoTrans, T(1), A.upper(), B);

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

///
///  :links: __lapack::trf__ -> file:flens/lapack/ge/trf.h
///          __blas::sm__ -> file:flens/blas/level3/sm.h
///