pub trait PackedExtension<FS: Field>: PackedFieldwhere
Self::Scalar: ExtensionField<FS>,{
type PackedSubfield: PackedField<Scalar = FS>;
// Required methods
fn cast_bases(packed: &[Self]) -> &[Self::PackedSubfield];
fn cast_bases_mut(packed: &mut [Self]) -> &mut [Self::PackedSubfield];
fn cast_exts(packed: &[Self::PackedSubfield]) -> &[Self];
fn cast_exts_mut(packed: &mut [Self::PackedSubfield]) -> &mut [Self];
fn cast_base(self) -> Self::PackedSubfield;
fn cast_base_ref(&self) -> &Self::PackedSubfield;
fn cast_base_mut(&mut self) -> &mut Self::PackedSubfield;
fn cast_ext(base: Self::PackedSubfield) -> Self;
fn cast_ext_ref(base: &Self::PackedSubfield) -> &Self;
fn cast_ext_mut(base: &mut Self::PackedSubfield) -> &mut Self;
}
Expand description
Trait represents a relationship between a packed struct of field elements and a packed struct of elements from an extension field.
This trait guarantees that one packed type has the same memory representation as the other, differing only in the scalar type and preserving the order of smaller elements.
This trait relation guarantees that the following iterators yield the same sequence of scalar elements:
use binius_field::{ExtensionField, packed::iter_packed_slice, PackedExtension, PackedField, Field};
fn ext_then_bases<'a, F, PE>(packed: &'a PE) -> impl Iterator<Item=F> + 'a
where
PE: PackedField<Scalar: ExtensionField<F>>,
F: Field,
{
packed.iter().flat_map(|ext| ext.iter_bases())
}
fn cast_then_iter<'a, F, PE>(packed: &'a PE) -> impl Iterator<Item=F> + 'a
where
PE: PackedExtension<F, Scalar: ExtensionField<F>>,
F: Field,
{
PE::cast_base_ref(packed).into_iter()
}
§Safety
In order for the above relation to be guaranteed, the memory representation of
PackedExtensionField
element must be the same as a slice of the underlying PackedField
element.
Required Associated Types§
type PackedSubfield: PackedField<Scalar = FS>
Required Methods§
fn cast_bases(packed: &[Self]) -> &[Self::PackedSubfield]
fn cast_bases_mut(packed: &mut [Self]) -> &mut [Self::PackedSubfield]
fn cast_exts(packed: &[Self::PackedSubfield]) -> &[Self]
fn cast_exts_mut(packed: &mut [Self::PackedSubfield]) -> &mut [Self]
fn cast_base(self) -> Self::PackedSubfield
fn cast_base_ref(&self) -> &Self::PackedSubfield
fn cast_base_mut(&mut self) -> &mut Self::PackedSubfield
fn cast_ext(base: Self::PackedSubfield) -> Self
fn cast_ext_ref(base: &Self::PackedSubfield) -> &Self
fn cast_ext_mut(base: &mut Self::PackedSubfield) -> &mut Self
Object Safety§
This trait is not object safe.