.TH "islet_morton" 3 "islet" \" -*- nroff -*- .ad l .nh .SH NAME islet_morton \- Morton code helpers .PP \- Encode and decode Morton (Z-order) codes for spatial indexing\&. .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "static uint64_t \fBmorton_set_1\fP (int16_t *p)" .br .RI "Encode multi-dimensional coordinates into Morton codes\&. " .ti -1c .RI "static uint64_t \fBmorton_set_2\fP (int16_t *p)" .br .RI "Encode a 2D point\&. See \fBmorton_set_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBmorton_set_3\fP (int16_t *p)" .br .RI "Encode a 3D point\&. See \fBmorton_set_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBmorton_set_4\fP (int16_t *p)" .br .RI "Encode a 4D point\&. See \fBmorton_set_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBmorton_set_2_32\fP (int32_t *p)" .br .RI "Encode a 2D x 32-bit point\&. Dense full-64-bit layout (2 x 32 bits); part of the dense config family, not the legacy 16-bit-lane sparse layout that \fBmorton_set_2()\fP uses\&. " .ti -1c .RI "static void \fBmorton_get_1\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a Morton code into a multi-dimensional coordinate\&. " .ti -1c .RI "static void \fBmorton_get_2\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a 2D Morton code\&. See \fBmorton_get_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBmorton_get_3\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a 3D Morton code\&. See \fBmorton_get_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBmorton_get_4\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a 4D Morton code\&. See \fBmorton_get_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBmorton_get_2_32\fP (int32_t *pos, uint64_t code)" .br .RI "Decode a 2D x 32-bit Morton code\&. Inverse of \fBmorton_set_2_32()\fP\&. " .in -1c .SH "Detailed Description" .PP Encode and decode Morton (Z-order) codes for spatial indexing\&. Morton codes interleave the bits of multi-dimensional coordinates to create a single linear ordering that preserves spatial locality\&. For example, in 2D: .PP Coordinate (x=5, y=3): .IP "\(bu" 2 x = 5 = 0b0101 (binary) .IP "\(bu" 2 y = 3 = 0b0011 (binary) .IP "\(bu" 2 Interleaved: 0b00110011 = 51 (y bits in odd positions, x in even) .PP .PP In 3D, the pattern extends with z bits in every third position\&. .PP Coordinate System: .IP "\(bu" 2 Input: int16_t signed coordinates (-32768 to 32767) .IP "\(bu" 2 Internal: uint16_t unsigned coordinates (0 to 65535) via offset mapping .IP "\(bu" 2 Output: uint64_t Morton code (48 bits for 3D with the upper 16 bits reserved; all 64 bits for 4D) .PP .PP The conversion from signed to unsigned preserves ordering: -32768 → 0, -32767 → 1, \&.\&.\&., 0 → 32768, \&.\&.\&., 32767 → 65535 .PP \fBNote\fP .RS 4 Currently optimized for 3D/4D with fast bit-manipulation algorithms (stride-3 packing for dims 1-3, dense stride-4 packing for dim 4, dense stride-2 packing for the 2D x 32-bit config)\&. 1D/2D/3D codes are bit-identical to v0\&.5\&.0; 4D codes are new\&. When compiled with -mbmi2 the encode and decode kernels use PDEP/PEXT for a 2-3× speedup over the scalar path (default-on, opt out with -DISLET_USE_PDEP=0)\&. .PP All dimensions share the uint64 key space: use one dimension per database\&. .RE .PP \fBSee also\fP .RS 4 \fBIslet core API\fP .PP \fBPoint utilities\fP .RE .PP .SH "Function Documentation" .PP .SS "void morton_get_1 (int16_t * pos, uint64_t code)\fR [inline]\fP, \fR [static]\fP" .PP Decode a Morton code into a multi-dimensional coordinate\&. These per-dimension specializations are the decode API\&. Each decodes exactly one dimension count; there is no runtime \fRdim\fP argument\&. Inverse of the matching morton_set_N()\&. .PP \fBParameters\fP .RS 4 \fIpos\fP Output point\&. Array of int16_t with space for the dimension count of the function used\&. .br \fIcode\fP Morton code to decode (64-bit)\&. .RE .PP \fBNote\fP .RS 4 The output coordinates will be in range -32768 to 32767 (int16_t)\&. .RE .PP \fBWarning\fP .RS 4 Decoding a Morton code that wasn't created by morton_set_N() with valid coordinates may produce unexpected results (garbage coordinates)\&. .RE .PP Example: .PP .nf uint64_t code = 0x123456789ABCULL; // Some Morton code int16_t point[3]; morton_get_3(point, code); // point now contains the decoded coordinates .fi .PP .PP \fBSee also\fP .RS 4 \fBmorton_get_1\fP \fBmorton_get_2\fP \fBmorton_get_4\fP .PP \fBmorton_set_1\fP \fBmorton_set_2\fP \fBmorton_set_3\fP \fBmorton_set_4\fP .PP islet_iter .RE .PP .SS "void morton_get_2_32 (int32_t * pos, uint64_t code)\fR [inline]\fP, \fR [static]\fP" .PP Decode a 2D x 32-bit Morton code\&. Inverse of \fBmorton_set_2_32()\fP\&. .PP \fBParameters\fP .RS 4 \fIpos\fP Output point\&. Array of int32_t with space for 2 elements\&. .br \fIcode\fP Morton code to decode (64-bit, dense layout)\&. .RE .PP .SS "uint64_t morton_set_1 (int16_t * p)\fR [inline]\fP, \fR [static]\fP" .PP Encode multi-dimensional coordinates into Morton codes\&. These per-dimension specializations are the encode API\&. Each encodes exactly one dimension count; there is no runtime \fRdim\fP argument to branch on, so the compiler sees a fully unrolled expression\&. .PP Algorithm (dims 1-3): .IP "1." 4 Convert signed int16_t to unsigned uint16_t (add 32768) .IP "2." 4 Spread each 16-bit coordinate across 48 bits (every 3rd bit) .IP "3." 4 Combine: code = spread(x) | spread(y)<<1 | spread(z)<<2 .PP .PP Dim 4 uses dense stride-4 packing that fills all 64 bits\&. Dims 1-3 code values are bit-identical to v0\&.5\&.0; 4D codes are new\&. .PP \fBParameters\fP .RS 4 \fIp\fP Input point\&. Array of int16_t with at least the dimension count of the function used\&. Coordinates range from -32768 to 32767\&. .RE .PP \fBReturns\fP .RS 4 64-bit Morton code\&. For 1-3D, uses 48 bits (16 bits per dimension) with the upper 16 bits reserved; 4D fills all 64 bits\&. .RE .PP Example (3D): .PP .nf int16_t point[3] = {10, \-5, 100}; uint64_t code = morton_set_3(point); // code now contains the interleaved bit representation .fi .PP .PP Example (round-trip verification): .PP .nf int16_t original[3] = {123, \-456, 789}; uint64_t code = morton_set_3(original); int16_t decoded[3]; morton_get_3(decoded, code); // decoded[0]==123, decoded[1]==\-456, decoded[2]==789 .fi .PP .PP \fBSee also\fP .RS 4 \fBmorton_set_1\fP \fBmorton_set_2\fP \fBmorton_set_4\fP .PP \fBmorton_get_1\fP \fBmorton_get_2\fP \fBmorton_get_3\fP \fBmorton_get_4\fP .PP islet_put .PP islet_get .RE .PP .SS "uint64_t morton_set_2_32 (int32_t * p)\fR [inline]\fP, \fR [static]\fP" .PP Encode a 2D x 32-bit point\&. Dense full-64-bit layout (2 x 32 bits); part of the dense config family, not the legacy 16-bit-lane sparse layout that \fBmorton_set_2()\fP uses\&. Algorithm: .IP "1." 4 Convert signed int32_t to unsigned uint32_t (add 2^31) .IP "2." 4 Spread each 32-bit coordinate across 64 bits (every 2nd bit) .IP "3." 4 Combine: code = spread2(x) | spread2(y)<<1 .PP .PP \fBParameters\fP .RS 4 \fIp\fP Input point\&. Array of int32_t with at least 2 elements\&. Coordinates range from -2147483648 to 2147483647\&. .RE .PP \fBReturns\fP .RS 4 64-bit Morton code filling all 64 bits (no reserved bits)\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for islet from the source code\&.