23enum ReprType { _u32, _u64 };
25using namespace shamrock::sfc;
29 void init_shamrock_math_sfc(py::module &m) {
31 py::module sfc_module = m.def_submodule(
"sfc",
"Space Filling curve Library");
34 "icoord_to_morton_3d_u64",
39 Convert a 3d integer coord to morton code
43 "morton_to_icoord_3d_u64",
44 [](
u64 m) -> std::array<u32, 3> {
46 return {
u32{ret.x()},
u32{ret.y()},
u32{ret.z()}};
49 Convert a morton code to 3d integer coord
53 "icoord_to_morton_3d_u32",
58 Convert a 3d integer coord to morton code
62 "morton_to_icoord_3d_u32",
63 [](
u32 m) -> std::array<u16, 3> {
65 return {
u16{ret.x()},
u16{ret.y()},
u16{ret.z()}};
68 Convert a morton code to 3d integer coord
72 "to_morton_grid_3d_u32_f32_3",
73 [](std::array<f32, 3> pos,
74 std::array<f32, 3> bmin,
75 std::array<f32, 3> bmax) -> std::array<u16, 3> {
76 f32_3 pos_{pos[0], pos[1], pos[2]};
77 f32_3 bmin_{bmin[0], bmin[1], bmin[2]};
78 f32_3 bmax_{bmax[0], bmax[1], bmax[2]};
81 return {
u16{ret.x()},
u16{ret.y()},
u16{ret.z()}};
85 "to_morton_grid_3d_u32_f64_3",
86 [](std::array<f64, 3> pos,
87 std::array<f64, 3> bmin,
88 std::array<f64, 3> bmax) -> std::array<u16, 3> {
89 f64_3 pos_{pos[0], pos[1], pos[2]};
90 f64_3 bmin_{bmin[0], bmin[1], bmin[2]};
91 f64_3 bmax_{bmax[0], bmax[1], bmax[2]};
94 return {
u16{ret.x()},
u16{ret.y()},
u16{ret.z()}};
98 "to_morton_grid_3d_u64_f32_3",
99 [](std::array<f32, 3> pos,
100 std::array<f32, 3> bmin,
101 std::array<f32, 3> bmax) -> std::array<u32, 3> {
102 f32_3 pos_{pos[0], pos[1], pos[2]};
103 f32_3 bmin_{bmin[0], bmin[1], bmin[2]};
104 f32_3 bmax_{bmax[0], bmax[1], bmax[2]};
107 return {
u32{ret.x()},
u32{ret.y()},
u32{ret.z()}};
111 "to_morton_grid_3d_u64_f64_3",
112 [](std::array<f64, 3> pos,
113 std::array<f64, 3> bmin,
114 std::array<f64, 3> bmax) -> std::array<u32, 3> {
115 f64_3 pos_{pos[0], pos[1], pos[2]};
116 f64_3 bmin_{bmin[0], bmin[1], bmin[2]};
117 f64_3 bmax_{bmax[0], bmax[1], bmax[2]};
120 return {
u32{ret.x()},
u32{ret.y()},
u32{ret.z()}};
124 "coord_to_hilbert_3d_u64",
129 Convert a 3d coordinate in the unit cube to hilbert codes
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
std::uint16_t u16
16 bit unsigned integer
Bit manipulation instruction implementation for SYCL.
hilbert curve implementation from killing J., 2004
Morton curve implementation.
Pybind11 include and definitions.