Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
sym_indices.h
Go to the documentation of this file.
1 
3 #ifndef __INT_SYM_INDICES_H__
4 #define __INT_SYM_INDICES_H__
5 
6 #include <assert.h>
7 
8 template<typename RAIterator>
9 int relativeSign(RAIterator s1b, RAIterator s1e, RAIterator s2b, RAIterator s2e)
10 {
11  int sz = s1e-s1b;
12  assert(sz == (int)(s2e-s2b));
13  int i, k;
14  int sign = 1;
15  std::vector<bool> seen(sz);
16 
17  for (i = 0;i < sz;i++) seen[i] = false;
18 
19  for (i = 0;i < sz;i++)
20  {
21  if (seen[i]) continue;
22  int j = i;
23  while (true)
24  {
25  for (k = 0;k < sz && (!(*(s1b+k) == *(s2b+j)) || seen[k]);k++);
26  assert(k < sz);
27  j = k;
28  seen[j] = true;
29  if (j == i) break;
30  sign = -sign;
31  }
32  }
33 
34  return sign;
35 }
36 
37 template<typename T>
38 int relativeSign(const T& s1, const T& s2)
39 {
40  return relativeSign(s1.begin(), s1.end(), s2.begin(), s2.end());
41 }
42 
43 template <typename T>
44 int align_symmetric_indices(int order_A, T& idx_A, const int* sym_A,
45  int order_B, T& idx_B, const int* sym_B);
46 
47 template <typename T>
48 int align_symmetric_indices(int order_A, T& idx_A, const int* sym_A,
49  int order_B, T& idx_B, const int* sym_B,
50  int order_C, T& idx_C, const int* sym_C);
51 
52 template <typename T>
53 int overcounting_factor(int order_A, const T& idx_A, const int* sym_A,
54  int order_B, const T& idx_B, const int* sym_B,
55  int order_C, const T& idx_C, const int* sym_C);
56 
57 template <typename T>
58 int overcounting_factor(int order_A, const T& idx_A, const int* sym_A,
59  int order_B, const T& idx_B, const int* sym_B);
60 
61 #endif
62 
double sign(int par)
int align_symmetric_indices(int order_A, T &idx_A, const int *sym_A, int order_B, T &idx_B, const int *sym_B)
Definition: sym_indices.cxx:40
int relativeSign(RAIterator s1b, RAIterator s1e, RAIterator s2b, RAIterator s2e)
Definition: sym_indices.h:9
int overcounting_factor(int order_A, const T &idx_A, const int *sym_A, int order_B, const T &idx_B, const int *sym_B, int order_C, const T &idx_C, const int *sym_C)