rheolef  6.5
triangle_rotation_tst.cc
Go to the documentation of this file.
1 #include "rheolef/geo_element.h"
2 #include <boost/numeric/ublas/matrix.hpp>
3 using namespace std;
4 using namespace rheolef;
5 namespace ublas = boost::numeric::ublas;
6 
7 void dump (size_t order, int orient, size_t shift)
8 {
9  if (orient != 1 && orient != -1) {
10  cerr << "invalid orientation " << orient << endl;
11  exit (1);
12  }
13  if (shift > 3) {
14  cerr << "invalid shift " << shift << endl;
15  exit (1);
16  }
17  ublas::matrix<size_t> rot (order+1,order+1);
18  size_t coord[4];
19  for (size_t j = 1; j <= order-1; j++) {
20  for (size_t i = 1; i+j <= order-1; i++) {
21  size_t loc_tri_nnod = (order-1)*(order-2)/2;
22  size_t j1 = order - j;
23  size_t loc_itri_j = (loc_tri_nnod - (j1-1)*j1/2) + (i-1);
24  rot(i,j) = geo_element::fix_triangle_indirect (orient, shift, order, loc_itri_j);
25  }
26  }
27  cout << "order = "<<order<<", shift = " << shift << ", orientation = " << orient << endl;
28  for (size_t j = order-1; j >= 1; j--) {
29  for (size_t i = 1; i+j <= order-1; i++) {
30  cout << setw(5) << rot(i,j) << " ";
31  }
32  cout << endl;
33  }
34  cout << endl;
35 }
36 int main(int argc, char**argv) {
37  if (argc < 2) {
38  cerr << "usage: prog order orient shift" << endl;
39  exit (1);
40  }
41  size_t order = argc > 1 ? atoi(argv[1]) : 5;
42  for (size_t shift = 0; shift < 3; shift++) {
43  dump (order, 1, shift);
44  dump (order, -1, shift);
45  }
46 }
47