#include "remap.hpp" #include #include using namespace std; template static void test_z_order(uint64_t xmax, uint64_t ymax){ uint64_t c = 10; for (uint64_t x2 = 0; x2 <= xmax; ++x2) { for (uint64_t y2 = 0; y2 <= ymax; ++y2) { const T x = x2; const T y = y2; const auto z = remap::to_z_order(x, y); const auto p = remap::from_z_order(z); if (x != p.first || y != p.second) { cout << +x << ' ' << +y << " -> " << z << " -> " << +p.first << ' ' << +p.second << '\n'; c--; if(!c) return; } } } } template static void test_z_order_max(){ return test_z_order(std::numeric_limits::max(), std::numeric_limits::max()); } template static void test_hilbert(uint64_t xmax){ uint64_t c = 10; for (uint64_t x2 = 0; x2 <= xmax; ++x2) { for (uint64_t y2 = 0; y2 <= xmax; ++y2) { const T x = x2; const T y = y2; const remap::twice xmax2 = xmax+1; const auto z = remap::to_hilbert(xmax2, x, y); const auto p = remap::from_hilbert(xmax2, z); if (x != p.first || y != p.second) { cout << +x << ' ' << +y << " -> " << z << " -> " << +p.first << ' ' << +p.second << '\n'; c--; if(!c) return; } } } } template static void test_hilbert_max(){ return test_hilbert(std::numeric_limits::max()); } int main(int argc, char * argv[]) { //cout << "Z order: 8" << endl; //test_z_order_max(); cout << "Hilbert: 8" << endl; test_hilbert_max(); //cout << "Z order: 16" << endl; //test_z_order_max(); cout << "Hilbert: 16" << endl; test_hilbert_max(); }