1 #include <flens/flens.cxx>
2 #include <iostream>
3
4 using namespace flens;
5 using namespace std;
6
7 ///
8 /// In the `main` function we again start with a typedef for a `GeMatrix` with
9 /// elements of type `double` that are stored column-wise in memory. Also,
10 /// we define a suitable range operator.
11 ///
12 int
13 main()
14 {
15 typedef FullStorage<double, ColMajor> FS;
16 typedef GeMatrix<FS> GeMatrix;
17 const Underscore<GeMatrix::IndexType> _;
18
19 ///
20 /// Then we setup some matrix.
21 ///
22 GeMatrix A(3,4);
23 A = 1, 2, 3, 4,
24 5, 6, 7, 8,
25 9, 10, 11, 12;
26
27 cout << "A = " << A << endl;
28
29 ///
30 /// Matrix `B` is of type `const GeMatrix::View`. So in particular this matrix
31 /// is in const context.
32 ///
33 const auto B = A(_(1,3),_);
34
35 ///
36 /// Matrix `C` is of type `GeMatrix::ConstView` but it is *not* in const
37 /// context.
38 ///
39 auto C = B(_(1,3),_);
40
41 ///
42 /// Matrix `D` would be of type `GeMatrix::View` and would reference a part
43 /// of a matrix of type `GeMatrix::ConstView`. This would violate *const
44 /// correctness*.
45 auto D = C(_(1,3),_);
46
47 D(1,1) = 666;
48 cout << "D = " << D << endl;
49 }
2 #include <iostream>
3
4 using namespace flens;
5 using namespace std;
6
7 ///
8 /// In the `main` function we again start with a typedef for a `GeMatrix` with
9 /// elements of type `double` that are stored column-wise in memory. Also,
10 /// we define a suitable range operator.
11 ///
12 int
13 main()
14 {
15 typedef FullStorage<double, ColMajor> FS;
16 typedef GeMatrix<FS> GeMatrix;
17 const Underscore<GeMatrix::IndexType> _;
18
19 ///
20 /// Then we setup some matrix.
21 ///
22 GeMatrix A(3,4);
23 A = 1, 2, 3, 4,
24 5, 6, 7, 8,
25 9, 10, 11, 12;
26
27 cout << "A = " << A << endl;
28
29 ///
30 /// Matrix `B` is of type `const GeMatrix::View`. So in particular this matrix
31 /// is in const context.
32 ///
33 const auto B = A(_(1,3),_);
34
35 ///
36 /// Matrix `C` is of type `GeMatrix::ConstView` but it is *not* in const
37 /// context.
38 ///
39 auto C = B(_(1,3),_);
40
41 ///
42 /// Matrix `D` would be of type `GeMatrix::View` and would reference a part
43 /// of a matrix of type `GeMatrix::ConstView`. This would violate *const
44 /// correctness*.
45 auto D = C(_(1,3),_);
46
47 D(1,1) = 666;
48 cout << "D = " << D << endl;
49 }