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
     55
     56
     57
     58
#include <complex>
#include <iostream>
///
/// With header __flens.cxx__ all of FLENS gets included.
///
/// :links:  __flens.cxx__ -> file:flens/flens.cxx
#include <flens/flens.cxx>

using namespace std;
using namespace flens;

///
/// Elements are now defined to be *complex*
///
typedef complex<double>   T;

int
main()
{
    ///
    /// Like before we define convenient matrix/vector types ...
    ///
    typedef GeMatrix<FullStorage<T> >           Matrix;
    typedef DenseVector<Array<T> >              Vector;
    typedef Matrix::IndexType                   IndexType;
    typedef DenseVector<Array<IndexType> >      IndexVector;

    ///
    /// Then we setup another toy problem
    ///
    const IndexType n = 3;

    Matrix         A(n,n);
    Vector         b(n);
    IndexVector    piv(n);

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

    b = T( 10),
        T(-11),
        T(-2,-1);

    cerr << "A = " << A << endl;
    cerr << "b = " << b << endl;

    ///
    /// And solve it with __lapack::sv__
    ///
    /// :links: __lapack::sv__ -> doc:flens/lapack/ge/sv
    lapack::sv(A, piv, b);

    cerr << "A = " << A << endl;
    cerr << "piv = " << piv << endl;
    cerr << "x = " << b << endl;
}