pub struct FqSlice<'a, F: Field> {
fq: F,
limbs: &'a [u64],
start: usize,
end: usize,
}Expand description
A slice of an FqVector.
This immutably borrows the vector and implements Copy.
Fields§
§fq: F§limbs: &'a [u64]§start: usize§end: usizeImplementations§
Source§impl<F: Field> FqSlice<'_, F>
impl<F: Field> FqSlice<'_, F>
pub(super) fn entry_helper(&self, index: usize) -> F::ElementContainer
pub(super) fn first_nonzero_helper( &self, ) -> Option<(usize, F::ElementContainer)>
Source§impl<'a, F: Field> FqSlice<'a, F>
impl<'a, F: Field> FqSlice<'a, F>
pub fn prime(&self) -> ValidPrime
pub fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
pub fn entry(&self, index: usize) -> FieldElement<F>
Sourcepub fn iter(self) -> FqVectorIterator<'a, F> ⓘ
pub fn iter(self) -> FqVectorIterator<'a, F> ⓘ
TODO: implement prime 2 version
pub fn iter_nonzero(self) -> FqVectorNonZeroIterator<'a, F> ⓘ
pub fn first_nonzero(&self) -> Option<(usize, FieldElement<F>)>
pub fn is_zero(&self) -> bool
pub fn restrict(self, start: usize, end: usize) -> Self
Source§impl<F: Field> FqSlice<'_, F>
impl<F: Field> FqSlice<'_, F>
pub(super) fn offset(&self) -> usize
pub(super) fn limb_range(&self) -> Range<usize>
Sourcepub(super) fn limb_range_inner(&self) -> Range<usize>
pub(super) fn limb_range_inner(&self) -> Range<usize>
This function underflows if self.end() == 0, which happens if and only if we are taking a
slice of width 0 at the start of an FpVector. This should be a very rare edge case.
Dealing with the underflow properly would probably require using saturating_sub or
something of that nature, and that has a nontrivial (10%) performance hit.
pub(super) fn min_limb_mask(&self) -> u64
pub(super) fn max_limb_mask(&self) -> u64
pub(super) fn limb_masks(&self) -> (u64, u64)
Trait Implementations§
Source§impl<F: Field> Display for FqSlice<'_, F>
impl<F: Field> Display for FqSlice<'_, F>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
§Example
let fq = SmallFq::new(P2, 3);
let v = FqVector::from_slice(fq, &[fq.zero(), fq.one(), fq.a(), fq.a() * fq.a()]);
assert_eq!(&format!("{v}"), "[0, 1, a, a^2]");
// This only looks reasonable over prime fields of order less than 10
assert_eq!(&format!("{v:#}"), "01aa^2");impl<'a, F: Copy + Field> Copy for FqSlice<'a, F>
Auto Trait Implementations§
impl<'a, F> Freeze for FqSlice<'a, F>where
F: Freeze,
impl<'a, F> RefUnwindSafe for FqSlice<'a, F>where
F: RefUnwindSafe,
impl<'a, F> Send for FqSlice<'a, F>where
F: Send,
impl<'a, F> Sync for FqSlice<'a, F>where
F: Sync,
impl<'a, F> Unpin for FqSlice<'a, F>where
F: Unpin,
impl<'a, F> UnwindSafe for FqSlice<'a, 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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