File: initialize.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 (67 lines) | stat: -rw-r--r-- 1,393 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "testsuite.h"
#include <blitz/vector2.h>
#include <blitz/array.h>

using namespace blitz;

int main()
{
    Vector<int> a(6);
    a = 1, 4, 6, 3, 7, 8;

    BZTEST(a(0) == 1);
    BZTEST(a(1) == 4);
    BZTEST(a(2) == 6);
    BZTEST(a(3) == 3);
    BZTEST(a(4) == 7);
    BZTEST(a(5) == 8);
    cout << a << endl;

    Vector<int> b = a(Range(0,4,2));
    cout << b << endl;
//  b = -1, -2, -3;
//  workaround: use list initialization with Vector that has own storage
    Vector<int> bb(3);
    bb = -1, -2, -3;
    b = bb;
    cout << a << endl;
    cout << b << endl;
    BZTEST(a(0) == -1);
    BZTEST(a(1) == 4);
    BZTEST(a(2) == -2);
    BZTEST(a(3) == 3);
    BZTEST(a(4) == -3);
    BZTEST(a(5) == 8);

    Vector<int> c = a.reverse(firstDim);
    c = 0;
    BZTEST(a(0) == 0);
    BZTEST(a(1) == 0);
    BZTEST(a(2) == 0);
    BZTEST(a(3) == 0);
    BZTEST(a(4) == 0);
    BZTEST(a(5) == 0);
//  c = 8, 7, 3, 6, 4, 1;
//  workaround: use list initialization with Vector that has own storage
    Vector<int> cc(6);
    cc = 8, 7, 3, 6, 4, 1;
    c = cc;
    BZTEST(a(0) == 1);
    BZTEST(a(1) == 4);
    BZTEST(a(2) == 6);
    BZTEST(a(3) == 3);
    BZTEST(a(4) == 7);
    BZTEST(a(5) == 8);

    Array<int,1> d(5);
    d=1,-1,2,-2,0;
    BZTEST(d(0) == 1);
    BZTEST(d(1) == -1);
    BZTEST(d(2) == 2);
    BZTEST(d(3) == -2);
    BZTEST(d(4) == 0);

    
    return 0;
}