Views: What the hell is that?

Before we have a look at other matrix types, let me introduce views. The term view is used in FLENS to denote references to matrix or vector slices. And obviously it is adopted from the field of database systems.

So here a first example for

s01_t07_vectorviews.cc
  #include <flens/flens.h>
  #include <iostream>
  
  using namespace flens;
  using namespace std;
  
  typedef DenseVector<Array<double> >                DEVector;
  
  int
  main()
  {
      DEVector x(6);
      x = 1, 2, 3, 4, 5, 6;
  
      // views
      DEVector::View y = x(_(2,6));
      DEVector::View z = y(_(1,2,5));
  
      // copy
      DEVector c = x(_(2,6));
  
      cout << "Vectors x,c and views y, z:" << endl;
      cout << " x = " << x << endl;
      cout << " c = " << c << endl;
      cout << " y = " << y << endl;
      cout << " z = " << z << endl;
      cout << endl;
  
  
      // modify views:
      y(2) = 123;
      z(3) = 456;
      cout << "y(2) = 123;" << endl;
      cout << "z(3) = 456;" << endl;
      cout << endl;
  
      cout << "Here again x, c, y and z:" << endl;
      cout << " x = " << x << endl;
      cout << " c = " << c << endl;
      cout << " y = " << y << endl;
      cout << " z = " << z << endl;
  }

So what's this DEVector::View?

Now, this can be read as follows:

So why use this DEVector::View?

Here the output

Output of s01_t07_vectorviews
  Vectors x,c and views y, z:
   x = [6]
  1.000000  2.000000  3.000000  4.000000  5.000000  6.000000
  
   c = [5]
  2.000000  3.000000  4.000000  5.000000  6.000000
  
   y = [5]
  2.000000  3.000000  4.000000  5.000000  6.000000
  
   z = [3]
  2.000000  4.000000  6.000000
  
  
  y(2) = 123;
  z(3) = 456;
  
  Here again x, c, y and z:
   x = [6]
  1.000000  2.000000  123.000000  4.000000  5.000000  456.000000
  
   c = [5]
  2.000000  3.000000  4.000000  5.000000  6.000000
  
   y = [5]
  2.000000  123.000000  4.000000  5.000000  456.000000
  
   z = [3]
  2.000000  4.000000  456.000000