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

using namespace flens;
using namespace std;

int
main()
{
    typedef GeMatrix<FullStorage<double, ColMajor> >  GEMatrix;

    GEMatrix A(4,4);
    A = 1, 2, 3,  4,
        5, 6, 7,  8,
        9, 8, 7,  6,
        5, 4, 3, 20;

    cout << "A = " << A << endl;

    ///
    /// `U` is a triangular matrix referencing the upper triangular part.
    ///
    auto U = A.upper();
    cout << "U = " << U << endl;

    ///
    /// `SU` is a symmetric matrix.  The upper triangular part of `SU` is
    /// referencing `U` (which in turn references the upper part of `A`).
    ///
    auto SU = U.symmetric();
    cout << "SU = " << SU << endl;

    ///
    /// `SL` is a symmetric matrix.  The lower triangular part of `SL` is
    /// referencing the lower part of `A`).
    ///
    auto SL = A.lower().symmetric();
    cout << "SL = " << SL << endl;

    ///
    /// `L` is a unit triangular matrix referencing the lower part of `A`.
    /// The term "unit" denotes that elements on the diagonal are assumed to
    /// be one.
    ///
    auto L = A.lowerUnit();
    cout << "L = " << L << endl;

    return 0;
}