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

using namespace flens;
using namespace std;

int
main()
{
    typedef GeMatrix<FullStorage<double> >   GeMatrix;
    typedef DenseVector<Array<double> >      DenseVector;
    typedef typename DenseVector::IndexType  IndexType;

    const Underscore<IndexType>  _;

    GeMatrix     A(43);
    DenseVector  x(4);

///
/// Setup the matrix $A$.
///
    A = 1, 5,  9,
        2, 6, 10,
        3, 7, 11,
        4, 8, 12;

///
/// Initially the first the elements of $x$ contain the right hand side vector
/// $b$.  For convenience we define a vector view $b$ that references these
/// elements.
///
    auto b = x(_(1,3));

///
/// Setup vector $b$.
///
    b = 30,
        70,
       110;

///
/// Find the minimal norm solution of $A^T x = b$.
///
    lapack::ls(Trans, A, x);

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

    return 0;
}