hilbert
Hilbert curve encoding and decoding between coordinates and curve indices.
Functions:
-
right_shift–Shift a tensor of bits right by
kpositions, padding the vacated positions with zeros. -
binary2gray–Convert bits from the binary code to the Gray code.
-
gray2binary–Convert bits from the Gray code back to the binary code.
-
encode–Encode integer grid coordinates into their Hilbert curve indices.
-
decode–Decode Hilbert curve indices back into integer grid coordinates.
right_shift
¶
Shift a tensor of bits right by k positions, padding the vacated positions with zeros.
Parameters:
-
binary(Tensor) –Tensor of bits, most significant bit first along
axis. -
k(int, default:1) –Number of positions to shift by.
-
axis(int, default:-1) –Axis holding the bits.
Returns:
-
Tensor–The shifted bits, same shape as
binary.
binary2gray
¶
Convert bits from the binary code to the Gray code.
Parameters:
-
binary(Tensor) –Tensor of bits, most significant bit first along
axis. -
axis(int, default:-1) –Axis holding the bits.
Returns:
-
Tensor–The Gray-coded bits, same shape as
binary.
gray2binary
¶
Convert bits from the Gray code back to the binary code.
Parameters:
-
gray(Tensor) –Tensor of Gray-coded bits, most significant bit first along
axis. -
axis(int, default:-1) –Axis holding the bits.
Returns:
-
Tensor–The binary bits, same shape as
gray.
encode
¶
Encode integer grid coordinates into their Hilbert curve indices.
Parameters:
-
locs(Tensor) –Integer coordinates \((N, \text{num\_dims})\), each in \([0, 2^{\text{num\_bits}})\).
-
num_dims(int) –Number of dimensions of the grid.
-
num_bits(int) –Number of bits per dimension.
num_dimstimesnum_bitsmust fit in anint64.
Returns:
-
Tensor–The Hilbert indices, shape \((N,)\) and dtype
int64.
decode
¶
Decode Hilbert curve indices back into integer grid coordinates.
Parameters:
-
hilberts(Tensor) –Hilbert indices \((N,)\).
-
num_dims(int) –Number of dimensions of the grid.
-
num_bits(int) –Number of bits per dimension.
num_dimstimesnum_bitsmust fit in anint64.
Returns:
-
Tensor–The integer coordinates, shape \((N, \text{num\_dims})\) and dtype
int64.