34 namespace energybased {
37 template<
typename IntType,
int Dim>
41 for (
int d = Dim - 1; d >= 0; d--) {
61 return (a[0] == b[0]) && (a[1] == b[1]);
64 template<
typename IntType,
int Dim>
68 for (
int d = Dim - 1; d >= 0; d--) {
88 return (a[1] == b[1]) ? a[0] < b[0] : a[1] < b[1];
91 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);
132 const size_t HalfBitLength =
sizeof(
unsigned int) << 2;
140 unsigned int x_lo[2] = { coords[0],
144 unsigned int x_hi[2] = { coords[0] >> HalfBitLength,
145 coords[1] >> HalfBitLength };
148 unsigned int mask = ~0x0;
150 for (
unsigned int i = (HalfBitLength);i > 0; i = i >> 1) {
153 mask = mask ^ (mask << i);
156 x_lo[0] = (x_lo[0] | (x_lo[0] << i)) & mask;
157 x_lo[1] = (x_lo[1] | (x_lo[1] << i)) & mask;
159 x_hi[0] = (x_hi[0] | (x_hi[0] << i)) & mask;
160 x_hi[1] = (x_hi[1] | (x_hi[1] << i)) & mask;
164 mnr[0] = x_lo[0] | (x_lo[1] << 1);
167 mnr[1] = x_hi[0] | (x_hi[1] << 1);
171 template<
typename IntType>
175 const size_t BitLength =
sizeof(IntType) << 3;
181 for (
unsigned int i = (BitLength >> 1); i > 0; i = i >> 1) {
196 template<
typename IntType,
int Dim>
200 const size_t BitLength =
sizeof(IntType) << 3;
203 for (
int d = Dim - 1; d >= 0; d--) {
206 int msb = (mostSignificantBit<IntType>(a[d] ^ b[d]) + (d * BitLength));
219 return mostSignificantBit<unsigned int>(a[0] ^ b[0]);
void interleaveBits(const IntType coords[Dim], IntType mnr[Dim])
bool mortonComparerLess< unsigned int, 2 >(const unsigned int a[2], const unsigned int b[2])
int lowestCommonAncestorLevel(const IntType a[Dim], const IntType b[Dim])
void interleaveBits< unsigned int, 2 >(const unsigned int coords[2], unsigned int mnr[2])
int mostSignificantBit(IntType x)
bool mortonComparerEqual< unsigned int, 2 >(const unsigned int a[2], const unsigned int b[2])
bool mortonComparerEqual< unsigned int, 1 >(const unsigned int a[1], const unsigned int b[1])
int lowestCommonAncestorLevel< unsigned int, 1 >(const unsigned int a[1], const unsigned int b[1])
bool mortonComparerLess< unsigned int, 1 >(const unsigned int a[1], const unsigned int b[1])
bool mortonComparerLess(const IntType a[Dim], const IntType b[Dim])
The namespace for all OGDF objects.
bool mortonComparerEqual(const IntType a[Dim], const IntType b[Dim])
void interleaveBits< unsigned int, 1 >(const unsigned int coords[1], unsigned int mnr[1])