[−][src]Function moore_hilbert::coordinates_to_index
pub fn coordinates_to_index(
bits_per_dimension: BitsPerDimensionType,
coords: &[HilbertCoordinate]
) -> Result<HilbertIndex, ()>
Convert coordinates of a point on a Hilbert curve to its index
Arguments
bits_per_dimension
- Number of bits/coordinate.coords
- Slice of coordinate values
Returns
index
- Output index value. nDims*nBits bits.
Assumptions
length of coords
* bits_per_dimension
<= (sizeof HilbertIndex
) * (bits_per_byte
)
Example
let bits_per_dimension = 8; let r = moore_hilbert::coordinates_to_index(bits_per_dimension, &vec![1,2,3]).unwrap(); assert_eq!(r, 36);