Gröbner basis project
Codebase for research into Gröbner basis computation
test_exponent_access.cxx
1 #include <cstdlib>
2 #include <iostream>
3 using std::cout; using std::endl;
4 
5 class T {
6 public:
7  T(int n) { a = new int[n]; }
8  ~T() { delete [] a; }
9  int operator[](int i) const { return a[i]; }
10  int & operator[](int i) { return a[i]; }
11 private:
12  int * a;
13 };
14 
15 template<int n>
16 class U {
17 public:
18  U() { }
19  ~U() { }
20  int operator[](int i) const { return a[i]; }
21  int & operator[](int i) { return a[i]; }
22 private:
23  int a[n];
24 };
25 
26 
27 int main(int argc, char * argv []) {
28  T * t = new T(8);
29  U<8> * u = new U<8>;
30  U<9> v;
31 
32  for (int i = 0; i < 8; ++i) {
33  (*t)[i] = i;
34  (*u)[i] = i;
35  v[i] = i;
36  }
37  v[8] = 8;
38 
39  uint64_t a;
40  #define VERSION 1
41  for (uint64_t i = 0; i < 4000000000; ++i) {
42  #if VERSION==1
43  if (i == 0) cout << "version a\n";
44  a = (*t)[4] * i;
45  if (i % 2 == 0) (*t)[4] *= 2;
46  else (*t)[4] /= 2;
47  #elif VERSION==2
48  if (i == 0) cout << "version b\n";
49  a = (*u)[4] * i;
50  if (i % 2 == 0) (*u)[4] *= 2;
51  else (*u)[4] /= 2;
52  #elif VERSION==3
53  if (i == 0) cout << "version c\n";
54  a = v[4] * i;
55  if (i % 2 == 0) v[4] *= 2;
56  else v[4] /= 2;
57  #endif
58  }
59 
60  for (int i = 0; i < 8; ++i)
61  cout << (*t)[i] << ',';
62  cout << endl;
63 
64  for (int i = 0; i < 8; ++i)
65  cout << (*u)[i] << ',';
66  cout << endl;
67 
68  for (int i = 0; i < 9; ++i)
69  cout << v[i] << ',';
70  cout << endl;
71 
72  delete t;
73  delete u;
74 }