You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
#include "remap.hpp"
|
|
|
|
#include <iostream>
|
|
#include <limits>
|
|
|
|
using namespace std;
|
|
|
|
template <typename T>
|
|
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 <typename T>
|
|
static void test_z_order_max(){
|
|
return test_z_order<T>(std::numeric_limits<T>::max(), std::numeric_limits<T>::max());
|
|
}
|
|
|
|
template <typename T>
|
|
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<T> 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 <typename T>
|
|
static void test_hilbert_max(){
|
|
return test_hilbert<T>(std::numeric_limits<T>::max());
|
|
}
|
|
|
|
int main(int argc, char * argv[]) {
|
|
//cout << "Z order: 8" << endl;
|
|
//test_z_order_max<uint8_t>();
|
|
cout << "Hilbert: 8" << endl;
|
|
test_hilbert_max<uint8_t>();
|
|
//cout << "Z order: 16" << endl;
|
|
//test_z_order_max<uint16_t>();
|
|
cout << "Hilbert: 16" << endl;
|
|
test_hilbert_max<uint16_t>();
|
|
}
|
|
|