TwoAdicMultiplicativeCoset

Struct TwoAdicMultiplicativeCoset 

Source
pub struct TwoAdicMultiplicativeCoset<F: TwoAdicField> { /* private fields */ }
Expand description

Coset of a subgroup of the group of units of a finite field of order equal to a power of two.

§Examples

    TwoAdicField,
    PrimeCharacteristicRing,
    coset::TwoAdicMultiplicativeCoset
};
type F = BabyBear;
let log_size = 3;
let shift = F::from_u64(7);
let mut coset = TwoAdicMultiplicativeCoset::new(shift, log_size).unwrap();
let generator = coset.subgroup_generator();

// Coset elements can be queried by index
assert_eq!(coset.element(4), shift * generator.exp_u64(4));

// Coset elements can be iterated over in the canonical order
assert_eq!(
    coset.iter().collect_vec(),
    (0..1 << log_size).map(|i| shift * generator.exp_u64(i)).collect_vec()
);

// Cosets can be (element-wise) raised to a power of 2, either maintaining
// the shift and raising only the subgroup, or raising both.
let coset_shrunk_subgroup = coset.shrink_coset(2).unwrap();
assert_eq!(
    coset_shrunk_subgroup.subgroup_generator(),
    coset.subgroup_generator().exp_power_of_2(2),
);
assert_eq!(
    coset_shrunk_subgroup.shift(),
    coset.shift()
);

let coset_power = coset.exp_power_of_2(2).unwrap();
assert_eq!(
    coset_power.subgroup_generator(),
    coset.subgroup_generator().exp_power_of_2(2),
);
assert_eq!(
    coset_power.shift(),
    coset.shift().exp_power_of_2(2),
);

Implementations§

Source§

impl<F: TwoAdicField> TwoAdicMultiplicativeCoset<F>

Source

pub fn new(shift: F, log_size: usize) -> Option<Self>

Returns the coset shift * <generator>, where generator is a canonical (i. e. fixed in the implementation of F: TwoAdicField) generator of the unique subgroup of the units of F of order 2 ^ log_size. Returns None if log_size > F::TWO_ADICITY or if shift is zero.

§Arguments
  • shift: the value by which the subgroup is (multiplicatively) shifted
  • log_size: the size of the subgroup (and hence of the coset) is 2 ^ log_size. This determines the subgroup uniquely.
Source

pub fn subgroup_generator(&self) -> F

Returns the generator of the subgroup of order self.size().

Source

pub const fn shift(&self) -> F

Returns the shift of the coset.

Source

pub const fn shift_inverse(&self) -> F

Returns the inverse of the coset shift.

Source

pub const fn log_size(&self) -> usize

Returns the log2 of the size of the coset.

Source

pub const fn size(&self) -> usize

Returns the size of the coset.

Source

pub fn shrink_coset(&self, log_scale_factor: usize) -> Option<Self>

Returns a new coset with its subgroup reduced by a factor of 2^log_scale_factor in size (i. e. with generator equal to the 2^log_scale_factor-th power of that of the original coset), leaving the shift untouched. Note that new coset is contained in the original one. Returns None if log_scale_factor is greater than self.log_size().

Source

pub fn exp_power_of_2(&self, log_scale_factor: usize) -> Option<Self>

Returns the coset self^(2^log_scale_factor) (i. e. with shift and subgroup generator equal to the 2^log_scale_factor-th power of the original ones). Returns None if log_scale_factor is greater than self.log_size().

Source

pub fn shift_by(&self, scale: F) -> Self

Returns a new coset of the same size whose shift is equal to scale * self.shift.

Source

pub fn set_shift(&self, shift: F) -> Self

Returns a new coset where the shift has been set to shift

Source

pub fn contains(&self, element: F) -> bool

Checks if the given field element is in the coset

Source

pub fn element(&mut self, index: usize) -> F

Returns the element shift * generator^index, which is the index % self.size()-th element of self (and, in particular, the index-th element of self whenever index < self.size()).

Source

pub fn iter(&self) -> Take<Powers<F>>

Returns an iterator over the elements of the coset in the canonical order shift * generator^0, shift * generator^1, ..., shift * generator^(2^log_size - 1).

Trait Implementations§

Source§

impl<F: Clone + TwoAdicField> Clone for TwoAdicMultiplicativeCoset<F>

Source§

fn clone(&self) -> TwoAdicMultiplicativeCoset<F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + TwoAdicField> Debug for TwoAdicMultiplicativeCoset<F>

Source§

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

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

impl<F: TwoAdicField> IntoIterator for &TwoAdicMultiplicativeCoset<F>

Source§

type Item = F

The type of the elements being iterated over.
Source§

type IntoIter = Take<Powers<F>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<F: TwoAdicField> IntoIterator for TwoAdicMultiplicativeCoset<F>

Source§

type Item = F

The type of the elements being iterated over.
Source§

type IntoIter = Take<Powers<F>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<F: Copy + TwoAdicField> Copy for TwoAdicMultiplicativeCoset<F>

Auto Trait Implementations§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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
Source§

impl<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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