Skip to main content

SlicedPackedField

Struct SlicedPackedField 

Source
pub struct SlicedPackedField<F, PSub, const N: usize>(/* private fields */);
Expand description

A packed extension field stored as N packed subfield coordinate registers.

F is the extension scalar, PSub the packed subfield holding one coordinate of every lane, and N = <F as ExtensionField<PSub::Scalar>>::DEGREE the extension degree. See the module documentation for the layout and for which operations are generic here versus supplied per concrete extension.

Concrete packings are named through type aliases; see packed_ghash_sq for GHASH².

use binius_field::{Divisible, Field, GhashSq256b, PackedField, SlicedGhashSq2x256b};

let scalars = [GhashSq256b::ONE, GhashSq256b::MULTIPLICATIVE_GENERATOR];
let a = SlicedGhashSq2x256b::from_scalars(scalars);
let squared = a * a;
for i in 0..SlicedGhashSq2x256b::WIDTH {
    assert_eq!(squared.get(i), scalars[i] * scalars[i]);
}

Implementations§

Source§

impl<F, PSub: PackedField, const N: usize> SlicedPackedField<F, PSub, N>

Source

pub const fn from_coords(coords: [PSub; N]) -> Self

Wraps N coordinate registers, where coords[j] holds the β_j coordinate of every lane.

Source

pub const fn to_coords(self) -> [PSub; N]

Unwraps the N coordinate registers.

Trait Implementations§

Source§

impl<F, PSub: PackedField, const N: usize> Add<&SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Self) -> Self

Performs the + operation. Read more
Source§

impl<F, PSub, const N: usize> Add<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField,

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: F) -> Self

Performs the + operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Add for SlicedPackedField<F, PSub, N>

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> AddAssign<&SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>

Source§

fn add_assign(&mut self, rhs: &Self)

Performs the += operation. Read more
Source§

impl<F, PSub, const N: usize> AddAssign<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField,

Source§

fn add_assign(&mut self, rhs: F)

Performs the += operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> AddAssign for SlicedPackedField<F, PSub, N>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<F, PSub: Copy, const N: usize> Clone for SlicedPackedField<F, PSub, N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Debug for SlicedPackedField<F, PSub, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Default for SlicedPackedField<F, PSub, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Distribution<SlicedPackedField<F, PSub, N>> for StandardUniform

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> SlicedPackedField<F, PSub, N>

Generate a random value of T, using rng as the source of randomness.
§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl<F, PSub, const N: usize> Divisible<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField,

Source§

const LOG_N: usize = PSub::LOG_WIDTH

The log2 of the number of T elements that fit in Self.
Source§

fn value_iter(value: Self) -> impl ExactSizeIterator<Item = F> + Send + Clone

Returns an iterator over subdivisions of this underlier value, ordered from LSB to MSB.
Source§

fn ref_iter( value: &Self, ) -> impl ExactSizeIterator<Item = F> + Send + Clone + '_

Returns an iterator over subdivisions of this underlier reference, ordered from LSB to MSB.
Source§

fn slice_iter( slice: &[Self], ) -> impl ExactSizeIterator<Item = F> + Send + Clone + '_

Returns an iterator over subdivisions of a slice of underliers, ordered from LSB to MSB.
Source§

unsafe fn get_unchecked(&self, index: usize) -> F

Get element at index (LSB-first ordering) without bounds checking. Read more
Source§

unsafe fn set_unchecked(&mut self, index: usize, val: F)

Set element at index (LSB-first ordering) in place, without bounds checking. Read more
Source§

fn broadcast(val: F) -> Self

Create a value with val broadcast to all N positions.
Source§

fn from_iter(iter: impl Iterator<Item = F>) -> Self

Construct a value from an iterator of elements. Read more
Source§

const N: usize = _

The number of T elements that fit in Self.
Source§

fn get(&self, index: usize) -> T

Get element at index (LSB-first ordering). Read more
Source§

fn set(&mut self, index: usize, val: T)

Set element at index (LSB-first ordering), in place. Read more
Source§

impl<F, PSub, const N: usize> FieldOps for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField, Self: Square + InvertOrZero + Mul<Output = Self>,

Source§

type Scalar = F

Source§

fn zero() -> Self

Returns the zero element (additive identity).
Source§

fn one() -> Self

Returns the one element (multiplicative identity).
Source§

fn square_transpose<FSub: Field>(elems: &mut [Self])
where F: ExtensionField<FSub>,

Transpose the subfield elements in a slice of field elements. Read more
Source§

impl<F, PSub, const N: usize> Maskable<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField,

Source§

type Mask = <PSub as Maskable<<PSub as FieldOps>::Scalar>>::Mask

A precomputed mask selecting which T-lanes select keeps. Read more
Source§

fn make_mask(selectors: impl Iterator<Item = bool>) -> Self::Mask

Builds a mask from per-lane boolean selectors, in LSB-to-MSB lane order (the same ordering as Divisible). Consumes at most Divisible::N selectors; any lane past the end of the iterator, or whose selector is false, is not selected.
Source§

fn select(&self, mask: &Self::Mask) -> Self

Returns a value keeping the lanes selected when mask was built and zeroing the rest. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Mul<&SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>
where Self: Mul<Output = Self>,

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Self) -> Self

Performs the * operation. Read more
Source§

impl<F, PSub, const N: usize> Mul<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField, Self: Mul<Output = Self>,

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: F) -> Self

Performs the * operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Mul for SlicedPackedField<F, PSub, N>
where Self: WideMul,

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> MulAssign<&SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>
where Self: Mul<Output = Self>,

Source§

fn mul_assign(&mut self, rhs: &Self)

Performs the *= operation. Read more
Source§

impl<F, PSub, const N: usize> MulAssign<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField, Self: Mul<Output = Self>,

Source§

fn mul_assign(&mut self, rhs: F)

Performs the *= operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> MulAssign for SlicedPackedField<F, PSub, N>
where Self: Mul<Output = Self>,

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Neg for SlicedPackedField<F, PSub, N>

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<F, PSub, const N: usize> PackedField for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField, Self: Square + InvertOrZero + Mul<Output = Self> + WideMul<Output: Debug + Send + Sync + 'static>,

Source§

fn interleave(self, other: Self, log_block_len: usize) -> (Self, Self)

Interleaves blocks of this packed vector with another packed vector. Read more
Source§

fn unzip(self, other: Self, log_block_len: usize) -> (Self, Self)

Unzips interleaved blocks of this packed vector with another packed vector. Read more
Source§

fn from_fn(f: impl FnMut(usize) -> Self::Scalar) -> Self

Construct a packed field element from a function that returns scalar values by index.
Source§

unsafe fn spread_unchecked(self, log_block_len: usize, block_idx: usize) -> Self

Unsafe version of Self::spread. Read more
Source§

const LOG_WIDTH: usize = _

Base-2 logarithm of the number of field elements packed into one packed element. Read more
Source§

const WIDTH: usize = _

The number of field elements packed into one packed element. Read more
Source§

fn into_iter(self) -> impl Iterator<Item = Self::Scalar> + Send + Clone

Source§

fn iter(&self) -> impl Iterator<Item = Self::Scalar> + Send + Clone + '_

Source§

fn iter_slice( slice: &[Self], ) -> impl Iterator<Item = Self::Scalar> + Send + Clone + '_

Source§

fn set_single(scalar: Self::Scalar) -> Self

Initialize zero position with scalar, set other elements to zero.
Source§

fn from_scalars(values: impl IntoIterator<Item = Self::Scalar>) -> Self

Construct a packed field element from a sequence of scalars. Read more
Source§

fn pow(self, exp: u64) -> Self

Returns the value to the power exp.
Source§

fn spread(self, log_block_len: usize, block_idx: usize) -> Self

Spread takes a block of elements within a packed field and repeats them to the full packing width. Read more
Source§

impl<F, PSub: PartialEq, const N: usize> PartialEq for SlicedPackedField<F, PSub, N>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, F, PSub: PackedField, const N: usize> Product<&'a SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, Self: Mul<Output = Self>,

Source§

fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<F, PSub: PackedField, const N: usize> Product for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, Self: Mul<Output = Self>,

Source§

fn product<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<F, PSub: PackedField, const N: usize> Sub<&SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Self) -> Self

Performs the - operation. Read more
Source§

impl<F, PSub, const N: usize> Sub<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField,

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: F) -> Self

Performs the - operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> Sub for SlicedPackedField<F, PSub, N>

Source§

type Output = SlicedPackedField<F, PSub, N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> SubAssign<&SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>

Source§

fn sub_assign(&mut self, rhs: &Self)

Performs the -= operation. Read more
Source§

impl<F, PSub, const N: usize> SubAssign<F> for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField,

Source§

fn sub_assign(&mut self, rhs: F)

Performs the -= operation. Read more
Source§

impl<F, PSub: PackedField, const N: usize> SubAssign for SlicedPackedField<F, PSub, N>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<'a, F, PSub: PackedField, const N: usize> Sum<&'a SlicedPackedField<F, PSub, N>> for SlicedPackedField<F, PSub, N>

Source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<F, PSub: PackedField, const N: usize> Sum for SlicedPackedField<F, PSub, N>

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<F, PSub: Zeroable, const N: usize> Zeroable for SlicedPackedField<F, PSub, N>

§

fn zeroed() -> Self

Source§

impl<F, PSub: Copy, const N: usize> Copy for SlicedPackedField<F, PSub, N>

Source§

impl<F, PSub: Eq, const N: usize> Eq for SlicedPackedField<F, PSub, N>

Auto Trait Implementations§

§

impl<F, PSub, const N: usize> Freeze for SlicedPackedField<F, PSub, N>
where PSub: Freeze,

§

impl<F, PSub, const N: usize> RefUnwindSafe for SlicedPackedField<F, PSub, N>
where PSub: RefUnwindSafe, F: RefUnwindSafe,

§

impl<F, PSub, const N: usize> Send for SlicedPackedField<F, PSub, N>
where PSub: Send, F: Send,

§

impl<F, PSub, const N: usize> Sync for SlicedPackedField<F, PSub, N>
where PSub: Sync, F: Sync,

§

impl<F, PSub, const N: usize> Unpin for SlicedPackedField<F, PSub, N>
where PSub: Unpin, F: Unpin,

§

impl<F, PSub, const N: usize> UnsafeUnpin for SlicedPackedField<F, PSub, N>
where PSub: UnsafeUnpin,

§

impl<F, PSub, const N: usize> UnwindSafe for SlicedPackedField<F, PSub, N>
where PSub: UnwindSafe, F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Random for T
where StandardUniform: Distribution<T>,

Source§

fn random(rng: impl Rng) -> T

Generate random value
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more