#[non_exhaustive]pub struct HilbertLayout {
pub hilbert_order: u32,
pub hilbert_rank: u32,
}Expand description
Descriptor for the Hilbert space-filling curve layout.
Elements are ordered according to a Hilbert curve, which provides better spatial locality than Morton (Z-order): consecutive Hilbert indices always differ by exactly 1 in exactly one coordinate (L∞ distance = 1).
Constraints (enforced by HilbertLayout::new):
hilbert_order > 0hilbert_rank >= 2- Every tensor dimension must equal
2^hilbert_order(validated at shape-binding time via [LayoutDescriptor::validate_against_shape])
The normative index mapping is the Skilling (2004) algorithm; see
docs/spec/layouts/hilbert.md § Normative Index Mapping.
§Examples
use hurray_core::layout::{LayoutDescriptor, HilbertLayout};
// 2-D Hilbert curve, order 2 (4×4 tensor).
let layout = LayoutDescriptor::Hilbert(HilbertLayout::new(2, 2).unwrap());
assert_eq!(layout.tag(), 0x40);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.hilbert_order: u32Order of the Hilbert curve. MUST be > 0.
Each tensor dimension must equal 2^hilbert_order.
hilbert_rank: u32Number of curve dimensions. MUST equal the tensor rank. MUST be >= 2.
Implementations§
Source§impl HilbertLayout
impl HilbertLayout
Sourcepub fn new(hilbert_order: u32, hilbert_rank: u32) -> Result<Self>
pub fn new(hilbert_order: u32, hilbert_rank: u32) -> Result<Self>
Creates a new HilbertLayout, validating that hilbert_order > 0
and hilbert_rank >= 2.
Shape consistency (shape[k] == 2^hilbert_order for all k) is
deferred to [LayoutDescriptor::validate_against_shape] because
the layout descriptor does not carry the shape.
§Errors
Returns Error::InvalidLayout if hilbert_order == 0 or
hilbert_rank < 2.
§Examples
use hurray_core::layout::HilbertLayout;
let h = HilbertLayout::new(3, 2).unwrap(); // 8×8 tensor
assert_eq!(h.hilbert_order, 3);
assert_eq!(h.hilbert_rank, 2);
assert!(HilbertLayout::new(0, 2).is_err()); // order must be > 0
assert!(HilbertLayout::new(2, 1).is_err()); // rank must be >= 2Trait Implementations§
Source§impl Clone for HilbertLayout
impl Clone for HilbertLayout
Source§fn clone(&self) -> HilbertLayout
fn clone(&self) -> HilbertLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more