1 #include <flens/flens.cxx>
2 #include <iostream>
3
4 using namespace flens;
5 using namespace std;
6
7 int
8 main()
9 {
10 ///
11 /// You can use the underscore range operator `_(from, to)` to set the
12 /// index range of a matrix.
13 ///
14 /// Note that in previous versions of FLENS the underscore object `_` was
15 /// already defined as a global variable. You now have to define it
16 /// manually. This is because every matrix can now use different
17 /// index types (usually int or long).
18 ///
19 typedef GeMatrix<FullStorage<double, ColMajor> > GEMatrix;
20 Underscore<GEMatrix::IndexType> _;
21 GEMatrix A(_(0,3),_(-2,1));
22
23 for (int i=A.firstRow(); i<=A.lastRow(); ++i) {
24 for (int j=A.firstCol(); j<=A.lastCol(); ++j) {
25 A(i,j) = 100*i+j;
26 }
27 }
28
29 ///
30 /// Or define a `GeMatrix` type with a different index base. Here we set
31 /// the default base to 0 such that both, row and col indices, start at
32 /// zero.
33 ///
34 typedef IndexOptions<int, 0> ZeroBased;
35 typedef GeMatrix<FullStorage<double, ColMajor, ZeroBased> > GEMatrixZB;
36 GEMatrixZB B(3,3);
37
38 for (int i=B.firstRow(); i<=B.lastRow(); ++i) {
39 for (int j=B.firstCol(); j<=B.lastCol(); ++j) {
40 B(i,j) = 100*i+j;
41 }
42 }
43
44
45 ///
46 /// Print matrix dimensions and content. Note that this time we use
47 /// methods `rows()` and `cols()` which return range objects.
48 ///
49 cout << "A(" << A.rows() << ", " << A.cols() << ") = " << A << endl;
50 cout << "B(" << B.rows() << ", " << B.cols() << ") = " << B << endl;
51
52 return 0;
53 }
2 #include <iostream>
3
4 using namespace flens;
5 using namespace std;
6
7 int
8 main()
9 {
10 ///
11 /// You can use the underscore range operator `_(from, to)` to set the
12 /// index range of a matrix.
13 ///
14 /// Note that in previous versions of FLENS the underscore object `_` was
15 /// already defined as a global variable. You now have to define it
16 /// manually. This is because every matrix can now use different
17 /// index types (usually int or long).
18 ///
19 typedef GeMatrix<FullStorage<double, ColMajor> > GEMatrix;
20 Underscore<GEMatrix::IndexType> _;
21 GEMatrix A(_(0,3),_(-2,1));
22
23 for (int i=A.firstRow(); i<=A.lastRow(); ++i) {
24 for (int j=A.firstCol(); j<=A.lastCol(); ++j) {
25 A(i,j) = 100*i+j;
26 }
27 }
28
29 ///
30 /// Or define a `GeMatrix` type with a different index base. Here we set
31 /// the default base to 0 such that both, row and col indices, start at
32 /// zero.
33 ///
34 typedef IndexOptions<int, 0> ZeroBased;
35 typedef GeMatrix<FullStorage<double, ColMajor, ZeroBased> > GEMatrixZB;
36 GEMatrixZB B(3,3);
37
38 for (int i=B.firstRow(); i<=B.lastRow(); ++i) {
39 for (int j=B.firstCol(); j<=B.lastCol(); ++j) {
40 B(i,j) = 100*i+j;
41 }
42 }
43
44
45 ///
46 /// Print matrix dimensions and content. Note that this time we use
47 /// methods `rows()` and `cols()` which return range objects.
48 ///
49 cout << "A(" << A.rows() << ", " << A.cols() << ") = " << A << endl;
50 cout << "B(" << B.rows() << ", " << B.cols() << ") = " << B << endl;
51
52 return 0;
53 }