.. index:: pair: namespace; gpr::sfc .. _doxid-namespacegpr_1_1sfc: namespace gpr::sfc ================== .. toctree:: :hidden: Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace sfc { // global variables uint8_t :ref:`MORTON_TO_HILBERT_LUT`[96] = { 48, 33, 27, 34, 47, 78, 28, 77, 66, 29, 51, 52, 65, 30, 72, 63, 76, 95, 75, 24, 53, 54, 82, 81, 18, 3, 17, 80, 61, 4, 62, 15, 0, 59, 71, 60, 49, 50, 86, 85, 84, 83, 5, 90, 79, 56, 6, 89, 32, 23, 1, 94, 11, 12, 2, 93, 42, 41, 13, 14, 35, 88, 36, 31, 92, 37, 87, 38, 91, 74, 8, 73, 46, 45, 9, 10, 7, 20, 64, 19, 70, 25, 39, 16, 69, 26, 44, 43, 22, 55, 21, 68, 57, 40, 58, 67, }; // global functions uint32_t :ref:`morton_3d`(uint32_t x, uint32_t y, uint32_t z); uint32_t :ref:`morton_to_hilbert_3d`(uint32_t morton, uint32_t bits); uint32_t :ref:`hilbert_3d`(double x, double y, double z, double min_coord, double scale, uint32_t bits = 10); std::vector :ref:`hilbert_permutation`(const double* coords, size_t n_atoms, uint32_t bits = 10); } // namespace sfc .. _details-namespacegpr_1_1sfc: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Global Variables ---------------- .. index:: pair: variable; MORTON_TO_HILBERT_LUT .. _doxid-namespacegpr_1_1sfc_1a56d4a86a989db8d9cd859891398d81e1: .. ref-code-block:: cpp :class: doxyrest-title-code-block uint8_t MORTON_TO_HILBERT_LUT[96] = { 48, 33, 27, 34, 47, 78, 28, 77, 66, 29, 51, 52, 65, 30, 72, 63, 76, 95, 75, 24, 53, 54, 82, 81, 18, 3, 17, 80, 61, 4, 62, 15, 0, 59, 71, 60, 49, 50, 86, 85, 84, 83, 5, 90, 79, 56, 6, 89, 32, 23, 1, 94, 11, 12, 2, 93, 42, 41, 13, 14, 35, 88, 36, 31, 92, 37, 87, 38, 91, 74, 8, 73, 46, 45, 9, 10, 7, 20, 64, 19, 70, 25, 39, 16, 69, 26, 44, 43, 22, 55, 21, 68, 57, 40, 58, 67, } 96-byte LUT for Morton->Hilbert conversion. 12 transform states x 8 octants = 96 entries. Upper bits encode next transform state, lower 3 bits encode Hilbert sub-index. Global Functions ---------------- .. index:: pair: function; morton_3d .. _doxid-namespacegpr_1_1sfc_1a0b4d72ffb67311d3a475ea96fc77381e: .. ref-code-block:: cpp :class: doxyrest-title-code-block uint32_t morton_3d(uint32_t x, uint32_t y, uint32_t z) Compute 3D Morton (Z-order) index from integer coordinates. Morton index interleaves bits: xyz -> ...z2y2x2z1y1x1z0y0x0 Uses pdep intrinsic on BMI2-capable CPUs, otherwise bit manipulation. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - x - X coordinate (0 to 2^bits - 1) * - y - Y coordinate (0 to 2^bits - 1) * - z - Z coordinate (0 to 2^bits - 1) .. rubric:: Returns: Morton index .. index:: pair: function; morton_to_hilbert_3d .. _doxid-namespacegpr_1_1sfc_1ac26dd9d08eb4f0767bc7f4110d174289: .. ref-code-block:: cpp :class: doxyrest-title-code-block uint32_t morton_to_hilbert_3d(uint32_t morton, uint32_t bits) Convert Morton index to Hilbert index using 96-byte LUT. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - morton - Morton (Z-order) index * - bits - Number of bits per dimension (max 10 for 32-bit output) .. rubric:: Returns: Hilbert index .. index:: pair: function; hilbert_3d .. _doxid-namespacegpr_1_1sfc_1a54f2b4342bd5a78baf049f254761f74c: .. ref-code-block:: cpp :class: doxyrest-title-code-block uint32_t hilbert_3d(double x, double y, double z, double min_coord, double scale, uint32_t bits = 10) Compute 3D Hilbert index from floating-point coordinates. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - x - X coordinate * - y - Y coordinate * - z - Z coordinate * - min_coord - Minimum coordinate value (for normalization) * - scale - Coordinate range (max - min, for normalization) * - bits - Precision bits per dimension (default 10, giving 1024 levels) .. rubric:: Returns: Hilbert index .. index:: pair: function; hilbert_permutation .. _doxid-namespacegpr_1_1sfc_1af77f9eb9f248596b3a420de8b7912bbd: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector hilbert_permutation(const double* coords, size_t n_atoms, uint32_t bits = 10) Compute Hilbert-ordered permutation for a set of 3D points. Returns a permutation array such that iterating over atoms in permutation order visits them in Hilbert curve order (spatially coherent). .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - coords - Pointer to xyz coordinates, packed as [x0,y0,z0,x1,y1,z1,...] * - n_atoms - Number of atoms * - bits - Hilbert precision (default 10) .. rubric:: Returns: Permutation array where perm[i] is the original index of the i-th atom in Hilbert order