File: indexexpr-base.cpp

package info (click to toggle)
blitz%2B%2B 1%3A1.0.2%2Bds-4.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,580 kB
  • sloc: cpp: 57,803; python: 1,941; fortran: 1,510; f90: 852; makefile: 838; sh: 321
file content (42 lines) | stat: -rw-r--r-- 855 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "testsuite.h"
#include <blitz/array.h>

using namespace blitz;

// Test index operators with different bases. Tests bug XXX.

int main()
{
  Array<int,1> bar(3); // c-Array
  Array<int,1> qux(3,fortranArray); // fortran
  Array<int,1> foo(Range(5,7)); // custom
  Array<int,1> base(Range(5,15));
  Array<int,1> subbase(base(Range(7,11,2)));

  blitz::firstIndex ii;
  // Indexed assignment from 0
  bar = ii;
  BZTEST(bar(0)==0);
  BZTEST(bar(1)==1);
  BZTEST(bar(2)==2);
  cout << bar;
  // FortranArray
  qux = ii;
  BZTEST(qux(1)==1);
  BZTEST(qux(2)==2);
  BZTEST(qux(3)==3);
  cout << qux;
  // Indexed assignment on non-base-0
  foo = ii;
  BZTEST(foo(5)==5);
  BZTEST(foo(6)==6);
  BZTEST(foo(7)==7);
  cout << foo;
  subbase=ii;
  BZTEST(subbase(5)==5);
  BZTEST(subbase(6)==6);
  BZTEST(subbase(7)==7);
  cout << subbase;
  return 0;
}