pub struct FqVector<F: Field> {
fq: F,
len: usize,
limbs: Vec<u64>,
}Expand description
A vector over a finite field.
Interally, it packs entries of the vectors into limbs. However, this is an abstraction that must
not leave the fp library.
Fields§
§fq: F§len: usize§limbs: Vec<u64>Implementations§
Source§impl<F: Field> FqVector<F>
impl<F: Field> FqVector<F>
pub fn from_raw_parts(fq: F, len: usize, limbs: Vec<u64>) -> Self
pub fn fq(&self) -> F
pub const fn len(&self) -> usize
pub(super) fn limbs(&self) -> &[u64]
pub(super) fn limbs_mut(&mut self) -> &mut [u64]
pub(super) fn vec_mut(&mut self) -> &mut Vec<u64>
pub(super) fn len_mut(&mut self) -> &mut usize
Source§impl<F: Field> FqVector<F>
impl<F: Field> FqVector<F>
pub(super) fn scale_helper(&mut self, c: F::ElementContainer)
pub(super) fn entry_helper(&self, index: usize) -> F::ElementContainer
pub(super) fn set_entry_helper( &mut self, index: usize, value: F::ElementContainer, )
pub(super) fn add_helper(&mut self, other: &Self, c: F::ElementContainer)
pub(super) fn add_offset_helper( &mut self, other: &Self, c: F::ElementContainer, offset: usize, )
pub(super) fn add_basis_element_helper( &mut self, index: usize, value: F::ElementContainer, )
pub(super) fn copy_from_slice_helper(&mut self, other: &[F::ElementContainer])
pub(super) fn add_truncate_helper( &mut self, other: &Self, c: F::ElementContainer, ) -> Option<()>
pub(super) fn add_carry_helper<T>( &mut self, other: &Self, c: F::ElementContainer, rest: &mut [T], ) -> bool
pub(super) fn first_nonzero_helper( &self, ) -> Option<(usize, F::ElementContainer)>
Source§impl<F: Field> FqVector<F>
impl<F: Field> FqVector<F>
pub fn new(fq: F, len: usize) -> Self
pub fn new_with_capacity(fq: F, len: usize, capacity: usize) -> Self
pub fn from_slice(fq: F, slice: &[FieldElement<F>]) -> Self
pub fn from_bytes(fq: F, len: usize, data: &mut impl Read) -> Result<Self>
pub fn update_from_bytes(&mut self, data: &mut impl Read) -> Result<()>
pub fn to_bytes(&self, buffer: &mut impl Write) -> Result<()>
pub const fn is_empty(&self) -> bool
pub fn prime(&self) -> ValidPrime
pub fn slice(&self, start: usize, end: usize) -> FqSlice<'_, F>
pub fn slice_mut(&mut self, start: usize, end: usize) -> FqSliceMut<'_, F>
pub fn as_slice(&self) -> FqSlice<'_, F>
pub fn as_slice_mut(&mut self) -> FqSliceMut<'_, F>
pub fn add_basis_element(&mut self, index: usize, value: FieldElement<F>)
pub fn entry(&self, index: usize) -> FieldElement<F>
pub fn set_entry(&mut self, index: usize, value: FieldElement<F>)
pub fn iter(&self) -> FqVectorIterator<'_, F> ⓘ
pub fn iter_nonzero(&self) -> FqVectorNonZeroIterator<'_, F> ⓘ
pub fn set_to_zero(&mut self)
pub fn scale(&mut self, c: FieldElement<F>)
Sourcepub fn add_offset(&mut self, other: &Self, c: FieldElement<F>, offset: usize)
pub fn add_offset(&mut self, other: &Self, c: FieldElement<F>, offset: usize)
Add other to self on the assumption that the first offset entries of other are
empty.
pub fn add(&mut self, other: &Self, c: FieldElement<F>)
pub fn assign(&mut self, other: &Self)
Sourcepub fn assign_partial(&mut self, other: &Self)
pub fn assign_partial(&mut self, other: &Self)
A version of FqVector::assign that allows other to be shorter than self.
pub fn is_zero(&self) -> bool
Sourcepub fn extend_len(&mut self, len: usize)
pub fn extend_len(&mut self, len: usize)
This function ensures the length of the vector is at least len. See also
set_scratch_vector_size.
Sourcepub fn set_scratch_vector_size(&mut self, len: usize)
pub fn set_scratch_vector_size(&mut self, len: usize)
This clears the vector and sets the length to len. This is useful for reusing
allocations of temporary vectors.
Sourcepub fn copy_from_slice(&mut self, slice: &[FieldElement<F>])
pub fn copy_from_slice(&mut self, slice: &[FieldElement<F>])
This replaces the contents of the vector with the contents of the slice. The two must have the same length.
pub fn sign_rule(&self, other: &Self) -> bool
pub fn add_truncate(&mut self, other: &Self, c: FieldElement<F>) -> Option<()>
fn add_carry_limb<T>( &mut self, idx: usize, source: u64, c: FieldElement<F>, rest: &mut [T], ) -> bool
pub fn add_carry<T>( &mut self, other: &Self, c: FieldElement<F>, rest: &mut [T], ) -> bool
Sourcepub fn first_nonzero(&self) -> Option<(usize, FieldElement<F>)>
pub fn first_nonzero(&self) -> Option<(usize, FieldElement<F>)>
Find the index and value of the first non-zero entry of the vector. None if the vector is zero.
pub fn density(&self) -> f32
Trait Implementations§
Source§impl<F: Field> Arbitrary for FqVector<F>
impl<F: Field> Arbitrary for FqVector<F>
Source§type Parameters = FqVectorArbParams<F>
type Parameters = FqVectorArbParams<F>
The type of parameters that
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<FqVector<F>>
type Strategy = BoxedStrategy<FqVector<F>>
The type of
Strategy used to generate values of type Self.Source§fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
Source§impl<'de, F: Field + Deserialize<'de>> Deserialize<'de> for FqVector<F>
impl<'de, F: Field + Deserialize<'de>> Deserialize<'de> for FqVector<F>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<F: Eq + Field> Eq for FqVector<F>
impl<F: Field> StructuralPartialEq for FqVector<F>
Auto Trait Implementations§
impl<F> Freeze for FqVector<F>where
F: Freeze,
impl<F> RefUnwindSafe for FqVector<F>where
F: RefUnwindSafe,
impl<F> Send for FqVector<F>where
F: Send,
impl<F> Sync for FqVector<F>where
F: Sync,
impl<F> Unpin for FqVector<F>where
F: Unpin,
impl<F> UnwindSafe for FqVector<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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
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