File: slice-iterators.cpp

package info (click to toggle)
blitz%2B%2B 1%3A1.0.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,568 kB
  • sloc: cpp: 57,803; python: 1,941; fortran: 1,510; f90: 852; makefile: 833; sh: 321
file content (24 lines) | stat: -rw-r--r-- 599 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "testsuite.h"
#include <blitz/array.h>

using namespace blitz;

int main(int argc, char* argv[]) {
    Array<float,2> image(100, 200);
    for (int x=0;x<100;x++)
        for (int y=0;y<200;y++)
            image(x,y) = 1000*y+x;

    RectDomain<2>  rect_domain(shape(0,0),shape(99,0));
    Array<float,2> slice = image(rect_domain);

    unsigned k = 0;
    for (Array<float,2>::iterator i=slice.begin();i!=slice.end();++i)
        BZTEST(*i==k++);

    slice.reverseSelf(0);
    for (Array<float,2>::iterator i=slice.begin();i!=slice.end();++i)
        BZTEST(*i==--k);

    return 0;
}