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>
impl<F: TwoAdicField> TwoAdicMultiplicativeCoset<F>
Sourcepub fn new(shift: F, log_size: usize) -> Option<Self>
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) shiftedlog_size: the size of the subgroup (and hence of the coset) is2 ^ log_size. This determines the subgroup uniquely.
Sourcepub fn subgroup_generator(&self) -> F
pub fn subgroup_generator(&self) -> F
Returns the generator of the subgroup of order self.size().
Sourcepub const fn shift_inverse(&self) -> F
pub const fn shift_inverse(&self) -> F
Returns the inverse of the coset shift.
Sourcepub fn shrink_coset(&self, log_scale_factor: usize) -> Option<Self>
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().
Sourcepub fn exp_power_of_2(&self, log_scale_factor: usize) -> Option<Self>
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().
Sourcepub fn shift_by(&self, scale: F) -> Self
pub fn shift_by(&self, scale: F) -> Self
Returns a new coset of the same size whose shift is equal to scale * self.shift.
Sourcepub fn set_shift(&self, shift: F) -> Self
pub fn set_shift(&self, shift: F) -> Self
Returns a new coset where the shift has been set to shift
Trait Implementations§
Source§impl<F: Clone + TwoAdicField> Clone for TwoAdicMultiplicativeCoset<F>
impl<F: Clone + TwoAdicField> Clone for TwoAdicMultiplicativeCoset<F>
Source§fn clone(&self) -> TwoAdicMultiplicativeCoset<F>
fn clone(&self) -> TwoAdicMultiplicativeCoset<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug + TwoAdicField> Debug for TwoAdicMultiplicativeCoset<F>
impl<F: Debug + TwoAdicField> Debug for TwoAdicMultiplicativeCoset<F>
Source§impl<F: TwoAdicField> IntoIterator for &TwoAdicMultiplicativeCoset<F>
impl<F: TwoAdicField> IntoIterator for &TwoAdicMultiplicativeCoset<F>
Source§impl<F: TwoAdicField> IntoIterator for TwoAdicMultiplicativeCoset<F>
impl<F: TwoAdicField> IntoIterator for TwoAdicMultiplicativeCoset<F>
impl<F: Copy + TwoAdicField> Copy for TwoAdicMultiplicativeCoset<F>
Auto Trait Implementations§
impl<F> Freeze for TwoAdicMultiplicativeCoset<F>where
F: Freeze,
impl<F> RefUnwindSafe for TwoAdicMultiplicativeCoset<F>where
F: RefUnwindSafe,
impl<F> Send for TwoAdicMultiplicativeCoset<F>
impl<F> Sync for TwoAdicMultiplicativeCoset<F>
impl<F> Unpin for TwoAdicMultiplicativeCoset<F>where
F: Unpin,
impl<F> UnwindSafe for TwoAdicMultiplicativeCoset<F>where
F: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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