Skip to main content

FieldOps

Trait FieldOps 

Source
pub trait FieldOps:
    Clone
    + Neg<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Sum
    + Product
    + for<'a> Add<&'a Self, Output = Self>
    + for<'a> Sub<&'a Self, Output = Self>
    + for<'a> Mul<&'a Self, Output = Self>
    + for<'a> Sum<&'a Self>
    + for<'a> Product<&'a Self>
    + AddAssign
    + SubAssign
    + MulAssign
    + for<'a> AddAssign<&'a Self>
    + for<'a> SubAssign<&'a Self>
    + for<'a> MulAssign<&'a Self>
    + Square
    + InvertOrZero {
    type Scalar: Field;

    // Required methods
    fn zero() -> Self;
    fn one() -> Self;
    fn square_transpose<FSub: Field>(elems: &mut [Self])
       where Self::Scalar: ExtensionField<FSub>;

    // Provided method
    fn powers(&self) -> impl Iterator<Item = Self> { ... }
}
Expand description

Operations for types that represent vectors of field elements.

This trait abstracts over:

  • Field types (single field elements, which are trivially vectors of length 1)
  • PackedField types (SIMD-accelerated vectors of field elements)
  • Symbolic field types (for constraint system representations)

Mathematically, instances of this trait represent vectors of field elements where arithmetic operations like addition, subtraction, multiplication, squaring, and inversion are defined element-wise. For a packed field with width N, multiplying two values performs N independent field multiplications in parallel.

§Required Methods

  • zero() - Returns the additive identity (all elements are zero)
  • one() - Returns the multiplicative identity (all elements are one)

Required Associated Types§

Required Methods§

Source

fn zero() -> Self

Returns the zero element (additive identity).

Source

fn one() -> Self

Returns the one element (multiplicative identity).

Source

fn square_transpose<FSub: Field>(elems: &mut [Self])
where Self::Scalar: ExtensionField<FSub>,

Transpose the subfield elements in a slice of field elements.

§Arguments
  • elems - a slice of $n$ elements, where $n$ is the degee of the extension of Self::Scalar over FSub. They are overwritten with the result elements.
§Preconditions
  • elems.len() must equal Self::Scalar::DEGREE

Provided Methods§

Source

fn powers(&self) -> impl Iterator<Item = Self>

Iterate the powers of this value, beginning with 1 (the 0’th power).

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<F, PSub, const N: usize> FieldOps for SlicedPackedField<F, PSub, N>
where F: ExtensionField<PSub::Scalar>, PSub: PackedField, Self: Square + InvertOrZero + Mul<Output = Self>,

Source§

impl<F: Field> FieldOps for F

Source§

impl<U, Scalar> FieldOps for PackedPrimitiveType<U, Scalar>
where Self: Square + InvertOrZero + Mul<Output = Self>, U: UnderlierType + Divisible<Scalar::Underlier>, Scalar: BinaryField,

Source§

type Scalar = Scalar