p3_field

Trait AbstractField

Source
pub trait AbstractField:
    Sized
    + Default
    + Clone
    + Add<Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Neg<Output = Self>
    + Mul<Output = Self>
    + MulAssign
    + Sum
    + Product
    + Debug {
    type F: Field;

    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;
    const NEG_ONE: Self;
Show 23 methods // Required methods fn from_f(f: Self::F) -> Self; fn from_bool(b: bool) -> Self; fn from_canonical_u8(n: u8) -> Self; fn from_canonical_u16(n: u16) -> Self; fn from_canonical_u32(n: u32) -> Self; fn from_canonical_u64(n: u64) -> Self; fn from_canonical_usize(n: usize) -> Self; fn from_wrapped_u32(n: u32) -> Self; fn from_wrapped_u64(n: u64) -> Self; // Provided methods fn double(&self) -> Self { ... } fn square(&self) -> Self { ... } fn cube(&self) -> Self { ... } fn exp_u64(&self, power: u64) -> Self { ... } fn exp_const_u64<const POWER: u64>(&self) -> Self { ... } fn exp_power_of_2(&self, power_log: usize) -> Self { ... } fn mul_2exp_u64(&self, exp: u64) -> Self { ... } fn powers(&self) -> Powers<Self> { ... } fn shifted_powers(&self, start: Self) -> Powers<Self> { ... } fn powers_packed<P: PackedField<Scalar = Self>>( &self, ) -> PackedPowers<Self, P> { ... } fn shifted_powers_packed<P: PackedField<Scalar = Self>>( &self, start: Self, ) -> PackedPowers<Self, P> { ... } fn dot_product<const N: usize>(u: &[Self; N], v: &[Self; N]) -> Self { ... } fn try_div<Rhs>(self, rhs: Rhs) -> Option<<Self as Mul<Rhs>>::Output> where Rhs: Field, Self: Mul<Rhs> { ... } fn zero_vec(len: usize) -> Vec<Self> { ... }
}
Expand description

A generalization of Field which permits things like

  • an actual field element
  • a symbolic expression which would evaluate to a field element
  • an array of field elements

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const TWO: Self

Source

const NEG_ONE: Self

Required Associated Types§

Required Methods§

Source

fn from_f(f: Self::F) -> Self

Source

fn from_bool(b: bool) -> Self

Convert from a bool.

Source

fn from_canonical_u8(n: u8) -> Self

Convert from a canonical u8.

If the input is not canonical, i.e. if it exceeds the field’s characteristic, then the behavior is undefined.

Source

fn from_canonical_u16(n: u16) -> Self

Convert from a canonical u16.

If the input is not canonical, i.e. if it exceeds the field’s characteristic, then the behavior is undefined.

Source

fn from_canonical_u32(n: u32) -> Self

Convert from a canonical u32.

If the input is not canonical, i.e. if it exceeds the field’s characteristic, then the behavior is undefined.

Source

fn from_canonical_u64(n: u64) -> Self

Convert from a canonical u64.

If the input is not canonical, i.e. if it exceeds the field’s characteristic, then the behavior is undefined.

Source

fn from_canonical_usize(n: usize) -> Self

Convert from a canonical usize.

If the input is not canonical, i.e. if it exceeds the field’s characteristic, then the behavior is undefined.

Source

fn from_wrapped_u32(n: u32) -> Self

Source

fn from_wrapped_u64(n: u64) -> Self

Provided Methods§

Source

fn double(&self) -> Self

Source

fn square(&self) -> Self

Source

fn cube(&self) -> Self

Source

fn exp_u64(&self, power: u64) -> Self

Exponentiation by a u64 power.

The default implementation calls exp_u64_generic, which by default performs exponentiation by squaring. Rather than override this method, it is generally recommended to have the concrete field type override exp_u64_generic, so that any optimizations will apply to all abstract fields.

Source

fn exp_const_u64<const POWER: u64>(&self) -> Self

Source

fn exp_power_of_2(&self, power_log: usize) -> Self

Source

fn mul_2exp_u64(&self, exp: u64) -> Self

self * 2^exp

Source

fn powers(&self) -> Powers<Self>

Source

fn shifted_powers(&self, start: Self) -> Powers<Self>

Source

fn powers_packed<P: PackedField<Scalar = Self>>(&self) -> PackedPowers<Self, P>

Source

fn shifted_powers_packed<P: PackedField<Scalar = Self>>( &self, start: Self, ) -> PackedPowers<Self, P>

Source

fn dot_product<const N: usize>(u: &[Self; N], v: &[Self; N]) -> Self

Source

fn try_div<Rhs>(self, rhs: Rhs) -> Option<<Self as Mul<Rhs>>::Output>
where Rhs: Field, Self: Mul<Rhs>,

Source

fn zero_vec(len: usize) -> Vec<Self>

Allocates a vector of zero elements of length len. Many operating systems zero pages before assigning them to a userspace process. In that case, our process should not need to write zeros, which would be redundant. However, the compiler may not always recognize this.

In particular, vec![Self::ZERO; len] appears to result in redundant userspace zeroing. This is the default implementation, but implementors may wish to provide their own implementation which transmutes something like vec![0u32; len].

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<AF, const D: usize> AbstractField for BinomialExtensionField<AF, D>

Source§

const ZERO: Self = _

Source§

const ONE: Self = _

Source§

const TWO: Self = _

Source§

const NEG_ONE: Self = _

Source§

type F = BinomialExtensionField<<AF as AbstractField>::F, D>

Source§

impl<F: Field, const N: usize> AbstractField for FieldArray<F, N>

Source§

const ZERO: Self = _

Source§

const ONE: Self = _

Source§

const TWO: Self = _

Source§

const NEG_ONE: Self = _

Source§

type F = F