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

using namespace flens;
using namespace std;

int
main()
{
    typedef complex<double>             Complex;
    const Complex                       I(0,1);

    GeMatrix<FullStorage<Complex> >     A(33);
    DenseVector<Array<Complex> >        b(3);

///
/// Setup the raw data.
///
    A = 2, I,    0,
        0, 2, 1.+I,
        0, 0,    3;

///
/// $T$ is an upper triangular matrix referencing the upper triangular part
/// of matrix $A$.
///
    auto T = A.upper();
    cout << "T = " << T << endl;

///
/// Computes the inverse $T^{-1}$ of matrix $T$.
///
    int info = lapack::tri(T);

///
/// If `info` is not zero then matrix $T$ was singular.  To be more precise, in
/// this case one diagonal element was exactly zero.
///
    if (info!=0) {
        cerr << "T is singular" << endl;
        return info;
    }

    cout << "inv(T) = " << T << endl;

    return 0;
}