Debian Codegraph @

doc/examples/slicing.cpp

raw
1 #include <blitz/array.h>
2
3 using namespace blitz;
4
5 int main()
6 {
7 Array<int,2> A(6,6), B(3,3);
8
9 // Set the upper left quadrant of A to 5
10 A(Range(0,2), Range(0,2)) = 5;
11
12 // Set the upper right quadrant of A to an identity matrix
13 B = 1, 0, 0,
14 0, 1, 0,
15 0, 0, 1;
16 A(Range(0,2), Range(3,5)) = B;
17
18 // Set the fourth row to 1
19 A(3, Range::all()) = 1;
20
21 // Set the last two rows to 0
22 A(Range(4, toEnd), Range::all()) = 0;
23
24 // Set the bottom right element to 8
25 A(5,5) = 8;
26
27 cout << "A = " << A << endl;
28
29 return 0;
30 }
31