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

using namespace flens;
using namespace std;

int
main()
{
    typedef DenseVector<Array<double> >     RealDenseVector;
    typedef GeMatrix<FullStorage<double> >  RealGeMatrix;

    const int   n = 5;

    Permutation P(n);
    P.vector = 5, 3, 2, 1, 4;

    RealDenseVector                 x(5), y;

    x = 1, 2, 3, 4, 5;

    y = P*x;

    cout << "x = " << x << endl;
    cout << "y = P*x = " << y << endl;

    x = transpose(P)*y;
    cout << "x = P^T*y = " << x << endl;


    RealGeMatrix  I(n, n), B(n,n);
    I = 0;
    I.diag(0) = 1;

    B = P*I;
    cout << "B = P*I = " << B << endl;
}