32 #include <type_traits> 35 namespace energybased {
38 template<
typename IntType,
int Dim>
42 for (
int d = Dim - 1; d >= 0; d--) {
52 template<
typename IntType,
int Dim>
59 template<
typename IntType,
int Dim>
62 return a[0] == b[0] && a[1] == b[1];
65 template<
typename IntType,
int Dim>
69 for (
int d = Dim - 1; d >= 0; d--) {
79 template<
typename IntType,
int Dim>
86 template<
typename IntType,
int Dim>
89 return (a[1] == b[1]) ? a[0] < b[0] : a[1] < b[1];
92 template<
typename IntType,
int Dim>
96 const int BitLength =
sizeof(IntType) << 3;
99 for (
int d = 0; d < Dim; d++) {
108 for (
int i = 0; i < BitLength; ++i) {
110 for (
int d = 0; d < Dim; d++) {
112 mnr[k / BitLength] |= ((coords[d] >> i) & 0x1) << ( k % BitLength);
120 template<
typename IntType,
int Dim>
126 template<
typename IntType,
int Dim>
130 const size_t HalfBitLength =
sizeof(
unsigned int) << 2;
138 unsigned int x_lo[2] = { coords[0], coords[1] };
141 unsigned int x_hi[2] = { coords[0] >> HalfBitLength, coords[1] >> HalfBitLength };
144 unsigned int mask = ~0x0;
146 for (
unsigned int i = (HalfBitLength);i > 0; i = i >> 1) {
149 mask = mask ^ (mask << i);
152 x_lo[0] = (x_lo[0] | (x_lo[0] << i)) & mask;
153 x_lo[1] = (x_lo[1] | (x_lo[1] << i)) & mask;
155 x_hi[0] = (x_hi[0] | (x_hi[0] << i)) & mask;
156 x_hi[1] = (x_hi[1] | (x_hi[1] << i)) & mask;
160 mnr[0] = x_lo[0] | (x_lo[1] << 1);
163 mnr[1] = x_hi[0] | (x_hi[1] << 1);
167 template<
typename IntType>
171 const size_t BitLength =
sizeof(IntType) << 3;
177 for (
unsigned int i = (BitLength >> 1); i > 0; i = i >> 1) {
192 template<
typename IntType,
int Dim>
196 const size_t BitLength =
sizeof(IntType) << 3;
199 for (
int d = Dim - 1; d >= 0; d--) {
202 int msb = (mostSignificantBit<IntType>(a[d] ^ b[d]) + (d * BitLength));
212 template<
typename IntType,
int Dim>
215 return mostSignificantBit<unsigned int>(a[0] ^ b[0]);
std::enable_if< Dim !=1 &&Dim !=2, void >::type interleaveBits(const IntType coords[Dim], IntType mnr[Dim])
int mostSignificantBit(IntType x)
std::enable_if< Dim !=1, int >::type lowestCommonAncestorLevel(const IntType a[Dim], const IntType b[Dim])
std::enable_if< Dim !=1 &&Dim !=2, bool >::type mortonComparerEqual(const IntType a[Dim], const IntType b[Dim])
std::enable_if< Dim !=1 &&Dim !=2, bool >::type mortonComparerLess(const IntType a[Dim], const IntType b[Dim])
The namespace for all OGDF objects.