binius_field::underlier

Trait UnderlierWithBitOps

Source
pub trait UnderlierWithBitOps:
    UnderlierType
    + BitAnd<Self, Output = Self>
    + BitAndAssign<Self>
    + BitOr<Self, Output = Self>
    + BitOrAssign<Self>
    + BitXor<Self, Output = Self>
    + BitXorAssign<Self>
    + Shr<usize, Output = Self>
    + Shl<usize, Output = Self>
    + Not<Output = Self> {
    const ZERO: Self;
    const ONE: Self;
    const ONES: Self;

    // Required method
    fn fill_with_bit(val: u8) -> Self;

    // Provided methods
    fn from_fn<T>(f: impl FnMut(usize) -> T) -> Self
       where T: UnderlierType,
             Self: From<T> { ... }
    fn broadcast_subvalue<T>(value: T) -> Self
       where T: UnderlierType,
             Self: From<T> { ... }
    unsafe fn get_subvalue<T>(&self, i: usize) -> T
       where T: UnderlierType + NumCast<Self> { ... }
    unsafe fn set_subvalue<T>(&mut self, i: usize, val: T)
       where T: UnderlierWithBitOps,
             Self: From<T> { ... }
    unsafe fn spread<T>(self, log_block_len: usize, block_idx: usize) -> Self
       where T: UnderlierWithBitOps + NumCast<Self>,
             Self: From<T> { ... }
}
Expand description

Underlier type that supports bit arithmetic.

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const ONES: Self

Required Methods§

Source

fn fill_with_bit(val: u8) -> Self

Fill value with the given bit val must be 0 or 1.

Provided Methods§

Source

fn from_fn<T>(f: impl FnMut(usize) -> T) -> Self
where T: UnderlierType, Self: From<T>,

Source

fn broadcast_subvalue<T>(value: T) -> Self
where T: UnderlierType, Self: From<T>,

Broadcast subvalue to fill Self. Self::BITS/T::BITS is supposed to be a power of 2.

Source

unsafe fn get_subvalue<T>(&self, i: usize) -> T
where T: UnderlierType + NumCast<Self>,

Gets the subvalue from the given position. Function panics in case when index is out of range.

§Safety

i must be less than Self::BITS/T::BITS.

Source

unsafe fn set_subvalue<T>(&mut self, i: usize, val: T)
where T: UnderlierWithBitOps, Self: From<T>,

Sets the subvalue in the given position. Function panics in case when index is out of range.

§Safety

i must be less than Self::BITS/T::BITS.

Source

unsafe fn spread<T>(self, log_block_len: usize, block_idx: usize) -> Self
where T: UnderlierWithBitOps + NumCast<Self>, Self: From<T>,

Spread takes a block of sub_elements of T type within the current value and repeats them to the full underlier width.

§Safety

log_block_len + T::LOG_BITS must be less than or equal to Self::LOG_BITS. block_idx must be less than 1 << (Self::LOG_BITS - log_block_len).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UnderlierWithBitOps for u8

Source§

const ZERO: Self = 0u8

Source§

const ONE: Self = 1u8

Source§

const ONES: Self = 255u8

Source§

fn fill_with_bit(val: u8) -> Self

Source§

impl UnderlierWithBitOps for u16

Source§

const ZERO: Self = 0u16

Source§

const ONE: Self = 1u16

Source§

const ONES: Self = 65_535u16

Source§

fn fill_with_bit(val: u8) -> Self

Source§

impl UnderlierWithBitOps for u32

Source§

const ZERO: Self = 0u32

Source§

const ONE: Self = 1u32

Source§

const ONES: Self = 4_294_967_295u32

Source§

fn fill_with_bit(val: u8) -> Self

Source§

impl UnderlierWithBitOps for u64

Source§

const ZERO: Self = 0u64

Source§

const ONE: Self = 1u64

Source§

const ONES: Self = 18_446_744_073_709_551_615u64

Source§

fn fill_with_bit(val: u8) -> Self

Source§

impl UnderlierWithBitOps for u128

Source§

const ZERO: Self = 0u128

Source§

const ONE: Self = 1u128

Source§

const ONES: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

fn fill_with_bit(val: u8) -> Self

Implementors§

Source§

impl<const N: usize> UnderlierWithBitOps for SmallU<N>

Source§

const ZERO: Self = _

Source§

const ONE: Self = _

Source§

const ONES: Self = _