#[non_exhaustive]pub struct MortonLayout {
pub morton_bits: Vec<u32>,
}Expand description
Descriptor for the Morton (Z-order curve) layout.
Elements are stored by interleaving the bits of their dimension indices in round-robin order (LSB of dimension 0 first), producing a linear order with good spatial locality for multi-dimensional access patterns.
For each dimension k, shape[k] MUST satisfy shape[k] <= 2^morton_bits[k].
The buffer must hold exactly 2^(sum(morton_bits)) elements.
§Examples
use hurray_core::layout::{LayoutDescriptor, MortonLayout};
// 4×4 tensor: 2 bits per dimension.
let layout = LayoutDescriptor::Morton(MortonLayout::new(vec![2, 2]).unwrap());
assert_eq!(layout.tag(), 0x05);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.morton_bits: Vec<u32>Number of bits used per dimension in the Morton encoding. Every value MUST be > 0.
Implementations§
Source§impl MortonLayout
impl MortonLayout
Sourcepub fn new(morton_bits: Vec<u32>) -> Result<Self>
pub fn new(morton_bits: Vec<u32>) -> Result<Self>
Creates a new MortonLayout, validating that every entry in
morton_bits is greater than 0.
§Errors
Returns Error::InvalidLayout if any morton_bits[k] is 0, or if
morton_bits is empty.
§Examples
use hurray_core::layout::MortonLayout;
let m = MortonLayout::new(vec![2, 2]).unwrap();
assert_eq!(m.morton_bits, [2, 2]);
// Zero bits is invalid.
assert!(MortonLayout::new(vec![2, 0]).is_err());Trait Implementations§
Source§impl Clone for MortonLayout
impl Clone for MortonLayout
Source§fn clone(&self) -> MortonLayout
fn clone(&self) -> MortonLayout
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MortonLayout
impl Debug for MortonLayout
Source§impl ElementAddress for MortonLayout
impl ElementAddress for MortonLayout
impl Eq for MortonLayout
Source§impl Hash for MortonLayout
impl Hash for MortonLayout
Source§impl PartialEq for MortonLayout
impl PartialEq for MortonLayout
Source§fn eq(&self, other: &MortonLayout) -> bool
fn eq(&self, other: &MortonLayout) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for MortonLayout
Auto Trait Implementations§
impl Freeze for MortonLayout
impl RefUnwindSafe for MortonLayout
impl Send for MortonLayout
impl Sync for MortonLayout
impl Unpin for MortonLayout
impl UnsafeUnpin for MortonLayout
impl UnwindSafe for MortonLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more