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

using namespace flens;
using namespace std;


typedef GeMatrix<FullStorage<double> >  DGeMatrix;
typedef DenseVector<Array<double> >     DDenseVector;


// Each function call causes a malloc for a 4x4 matrix and a free at the end of
// scope.
void
foo()
{
    DGeMatrix A(4,4);
    A =  1,  2,  3,  4,
         5,  6,  7,  8,
         9101112,
        13141516;

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

int
main()
{
    // Always have in mind that the function is an essential inner core routine
    // doing only little computation but gets called many times.
    for (int i=0; i<100; ++i) {
        foo();
    }
}