9#include <kernel/shape.hpp>
26 template<
typename Shape_>
28 struct IndexRepresentative;
30 struct IndexRepresentative
43 typename IndexVectorIn,
44 typename IndexVectorOut>
45 static void compute(IndexVectorOut& ivo,
const IndexVectorIn& ivi);
51 struct IndexRepresentative< Shape::Hypercube<1> >
54 typename IndexVectorIn,
55 typename IndexVectorOut>
56 static void compute(IndexVectorOut& ivo,
const IndexVectorIn& ivi)
58 ivo[0] = std::min(ivi[0], ivi[1]);
59 ivo[1] = std::max(ivi[0], ivi[1]);
65 struct IndexRepresentative< Shape::Hypercube<2> >
68 typename IndexVectorIn,
69 typename IndexVectorOut>
70 static void compute(IndexVectorOut& ivo,
const IndexVectorIn& ivi)
72 ivo[0] = std::min(std::min(ivi[0], ivi[1]), std::min(ivi[2], ivi[3]));
76 while(ivi[i] != ivo[0])
81 if((i == 0) || (i == 3))
83 ivo[1] = std::min(ivi[1], ivi[2]);
84 ivo[2] = std::max(ivi[1], ivi[2]);
88 ivo[1] = std::min(ivi[0], ivi[3]);
89 ivo[2] = std::max(ivi[0], ivi[3]);
92 ivo[3] = ivi[0] + ivi[1] + ivi[2] + ivi[3] - ivo[0] - ivo[1] - ivo[2];
98 struct IndexRepresentative< Shape::Simplex<1> >
101 typename IndexVectorIn,
102 typename IndexVectorOut>
103 static void compute(IndexVectorOut& ivo,
const IndexVectorIn& ivi)
105 ivo[0] = std::min(ivi[0], ivi[1]);
106 ivo[1] = std::max(ivi[0], ivi[1]);
112 struct IndexRepresentative< Shape::Simplex<2> >
115 typename IndexVectorIn,
116 typename IndexVectorOut>
117 static void compute(IndexVectorOut& ivo,
const IndexVectorIn& ivi)
119 ivo[0] = std::min(std::min(ivi[0], ivi[1]), ivi[2]);
120 ivo[2] = std::max(std::max(ivi[0], ivi[1]), ivi[2]);
121 ivo[1] = ivi[0] + ivi[1] + ivi[2] - ivo[0] - ivo[2];