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

using namespace flens;
using namespace std;

int
main()
{
    typedef GeMatrix<FullStorage<double, ColMajor> >      DGeMatrix;
    typedef DGeMatrix::View                               DGeMatrixView;
    typedef DGeMatrix::ConstView                          DGeMatrixConstView;

    const Underscore<DGeMatrix::IndexType>  _;

    DGeMatrix  A(3,4);
    A = 1,  2,  3,  4,
        5,  6,  7,  8,
        9101112;

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

    auto       B = A(_(2,3),_);       // auto: DGeMatrixView,
                                      // B:    DGeMatrixView

    const auto C = B(_,_(2,4));       // auto: DGeMatrixView,
                                      // C:    const DGeMatrixView

    const auto D = C;                 // auto: DGeMatrixView,
                                      // D:    const DGeMatrixView

    const auto E = C(_,_(1,2));       // auto: DGeMatrixConstView,
                                      // E: const DGeMatrixConstView

    // auto F = C(_,_(1,2));          // auto: DGeMatrixConstView
                                      // F:    DGeMatrixConstView
    // cout << "F(1,1) = " << F(1,1)  // error: static assertion failure as you
    //      << endl;                  //        call the non-const operator.

}