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

using namespace std;
using namespace flens;

int
main()
{
///
/// Define a $3 \times 3$ triangular matrix with memory for $9$ doubles.
///
    TrMatrix<FullStorage<double> >    L(3, Lower);

///
/// Init L somehow
///
    L(1,1) = 11;
    L(2,1) = 21; L(2,2) = 22;
    L(3,1) = 31; L(3,2) = 32; L(3,3) = 33;

///
/// The following line is equivalent to:
/// `TrMatrix<FullStorage<double> >::GeneralView  A = L.general();`
///
    auto  A = L.general();

///
/// Change any element from the upper or lower triangular part
///
    A(1,3) = 42;
    A(2,2) = 42*2;
    A(3,1) = 42*3;

///
/// Note the output operator for `TrMatrix` only reads elements from the lower
/// triangular part from memory.  Elements from the upper part are just assumed
/// to be zero.
///
    cout << "A = " << A << endl;
    cout << "L = " << L << endl;
}