Swarm-NG  1.1
pair_calculation.hpp
1 // this file does not have guard since it is used by other headers
2 
4 template<int nbod>
5 GENERIC int first ( int ij ){
6  int i = nbod - 1 - ij / (nbod/2);
7  int j = ij % (nbod/2);
8  if (j < i)
9  return i;
10  else
11  return nbod - 1 - i - nbod%2 + 1;
12 }
13 
15 template<int nbod>
16 GENERIC int second ( int ij ){
17  int i = nbod - 1 - ij / (nbod/2);
18  int j = ij % (nbod/2);
19  if (j < i)
20  return j;
21  else
22  return nbod - 1 - j - nbod%2;
23 }
24