FqVector

Struct FqVector 

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

Source

pub fn from_raw_parts(fq: F, len: usize, limbs: Vec<u64>) -> Self

Source

pub fn fq(&self) -> F

Source

pub const fn len(&self) -> usize

Source

pub(super) fn limbs(&self) -> &[u64]

Source

pub(super) fn limbs_mut(&mut self) -> &mut [u64]

Source

pub(super) fn vec_mut(&mut self) -> &mut Vec<u64>

Source

pub(super) fn len_mut(&mut self) -> &mut usize

Source§

impl<F: Field> FqVector<F>

Source

pub(super) fn scale_helper(&mut self, c: F::ElementContainer)

Source

pub(super) fn entry_helper(&self, index: usize) -> F::ElementContainer

Source

pub(super) fn set_entry_helper( &mut self, index: usize, value: F::ElementContainer, )

Source

pub(super) fn add_helper(&mut self, other: &Self, c: F::ElementContainer)

Source

pub(super) fn add_offset_helper( &mut self, other: &Self, c: F::ElementContainer, offset: usize, )

Source

pub(super) fn add_basis_element_helper( &mut self, index: usize, value: F::ElementContainer, )

Source

pub(super) fn copy_from_slice_helper(&mut self, other: &[F::ElementContainer])

Source

pub(super) fn add_truncate_helper( &mut self, other: &Self, c: F::ElementContainer, ) -> Option<()>

Source

pub(super) fn add_carry_helper<T>( &mut self, other: &Self, c: F::ElementContainer, rest: &mut [T], ) -> bool
where for<'a> &'a mut T: TryInto<&'a mut Self>,

Source

pub(super) fn first_nonzero_helper( &self, ) -> Option<(usize, F::ElementContainer)>

Source§

impl<F: Field> FqVector<F>

Source

pub fn new(fq: F, len: usize) -> Self

Source

pub fn new_with_capacity(fq: F, len: usize, capacity: usize) -> Self

Source

pub fn from_slice(fq: F, slice: &[FieldElement<F>]) -> Self

Source

pub fn from_bytes(fq: F, len: usize, data: &mut impl Read) -> Result<Self>

Source

pub fn update_from_bytes(&mut self, data: &mut impl Read) -> Result<()>

Source

pub fn to_bytes(&self, buffer: &mut impl Write) -> Result<()>

Source

pub const fn is_empty(&self) -> bool

Source

pub fn prime(&self) -> ValidPrime

Source

pub fn slice(&self, start: usize, end: usize) -> FqSlice<'_, F>

Source

pub fn slice_mut(&mut self, start: usize, end: usize) -> FqSliceMut<'_, F>

Source

pub fn as_slice(&self) -> FqSlice<'_, F>

Source

pub fn as_slice_mut(&mut self) -> FqSliceMut<'_, F>

Source

pub fn add_basis_element(&mut self, index: usize, value: FieldElement<F>)

Source

pub fn entry(&self, index: usize) -> FieldElement<F>

Source

pub fn set_entry(&mut self, index: usize, value: FieldElement<F>)

Source

pub fn iter(&self) -> FqVectorIterator<'_, F>

Source

pub fn iter_nonzero(&self) -> FqVectorNonZeroIterator<'_, F>

Source

pub fn set_to_zero(&mut self)

Source

pub fn scale(&mut self, c: FieldElement<F>)

Source

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.

Source

pub fn add(&mut self, other: &Self, c: FieldElement<F>)

Source

pub fn assign(&mut self, other: &Self)

Source

pub fn assign_partial(&mut self, other: &Self)

A version of FqVector::assign that allows other to be shorter than self.

Source

pub fn is_zero(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

pub fn sign_rule(&self, other: &Self) -> bool

Source

pub fn add_truncate(&mut self, other: &Self, c: FieldElement<F>) -> Option<()>

Source

fn add_carry_limb<T>( &mut self, idx: usize, source: u64, c: FieldElement<F>, rest: &mut [T], ) -> bool
where for<'a> &'a mut T: TryInto<&'a mut Self>,

Source

pub fn add_carry<T>( &mut self, other: &Self, c: FieldElement<F>, rest: &mut [T], ) -> bool
where for<'a> &'a mut T: TryInto<&'a mut Self>,

Source

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.

Source

pub fn density(&self) -> f32

Trait Implementations§

Source§

impl<F: Field> Arbitrary for FqVector<F>

Source§

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

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

impl<F: Clone + Field> Clone for FqVector<F>

Source§

fn clone(&self) -> FqVector<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 + Field> Debug for FqVector<F>

Source§

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

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

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<F: Field> Display for FqVector<F>

Source§

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

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

impl<'a, F: Field> From<&'a FqVector<F>> for FqSlice<'a, F>

Source§

fn from(v: &'a FqVector<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: Field> From<&FqVector<F>> for Vec<FieldElement<F>>

Source§

fn from(vec: &FqVector<F>) -> Self

Converts to this type from the input type.
Source§

impl<'a, F: Field> From<&'a mut FqVector<F>> for FqSliceMut<'a, F>

Source§

fn from(v: &'a mut FqVector<F>) -> Self

Converts to this type from the input type.
Source§

impl<T: AsRef<[FieldElement<F>]>, F: Field> From<(F, T)> for FqVector<F>

Source§

fn from(data: (F, T)) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<FqVector<Fp<P2>>> for FpVector

Source§

fn from(x: FqVector<Fp<P2>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<FqVector<Fp<P3>>> for FpVector

Source§

fn from(x: FqVector<Fp<P3>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<FqVector<Fp<P5>>> for FpVector

Source§

fn from(x: FqVector<Fp<P5>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<FqVector<Fp<P7>>> for FpVector

Source§

fn from(x: FqVector<Fp<P7>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<FqVector<Fp<ValidPrime>>> for FpVector

Source§

fn from(x: FqVector<Fp<ValidPrime>>) -> Self

Converts to this type from the input type.
Source§

impl<F: Hash + Field> Hash for FqVector<F>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<F: PartialEq + Field> PartialEq for FqVector<F>

Source§

fn eq(&self, other: &FqVector<F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F> Serialize for FqVector<F>
where F: Serialize + Field,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> TryInto<&'a mut FqVector<Fp<P2>>> for &'a mut FpVector

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<&'a mut FqVector<Fp<P2>>, Self::Error>

Performs the conversion.
Source§

impl<'a> TryInto<&'a mut FqVector<Fp<P3>>> for &'a mut FpVector

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<&'a mut FqVector<Fp<P3>>, Self::Error>

Performs the conversion.
Source§

impl<'a> TryInto<&'a mut FqVector<Fp<P5>>> for &'a mut FpVector

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<&'a mut FqVector<Fp<P5>>, Self::Error>

Performs the conversion.
Source§

impl<'a> TryInto<&'a mut FqVector<Fp<P7>>> for &'a mut FpVector

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<&'a mut FqVector<Fp<P7>>, Self::Error>

Performs the conversion.
Source§

impl<'a> TryInto<&'a mut FqVector<Fp<ValidPrime>>> for &'a mut FpVector

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<&'a mut FqVector<Fp<ValidPrime>>, Self::Error>

Performs the conversion.
Source§

impl<F: Eq + Field> Eq for FqVector<F>

Source§

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,