Trait lambdaworks_math::field::traits::IsField

source ·
pub trait IsField: Debug + Clone {
    type BaseType: Clone + Debug + Unpin;

Show 14 methods // Required methods fn add(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType; fn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType; fn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType; fn neg(a: &Self::BaseType) -> Self::BaseType; fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>; fn div(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType; fn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool; fn zero() -> Self::BaseType; fn one() -> Self::BaseType; fn from_u64(x: u64) -> Self::BaseType; fn from_base_type(x: Self::BaseType) -> Self::BaseType; // Provided methods fn double(a: &Self::BaseType) -> Self::BaseType { ... } fn square(a: &Self::BaseType) -> Self::BaseType { ... } fn pow<T>(a: &Self::BaseType, exponent: T) -> Self::BaseType where T: IsUnsignedInteger { ... }
}
Expand description

Trait to add field behaviour to a struct.

Required Associated Types§

Required Methods§

source

fn add(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType

Returns the sum of a and b.

source

fn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType

Returns the multiplication of a and b.

source

fn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType

Returns the subtraction of a and b.

source

fn neg(a: &Self::BaseType) -> Self::BaseType

Returns the additive inverse of a.

source

fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>

Returns the multiplicative inverse of a.

source

fn div(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType

Returns the division of a and b.

source

fn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool

Returns a boolean indicating whether a and b are equal or not.

source

fn zero() -> Self::BaseType

Returns the additive neutral element.

source

fn one() -> Self::BaseType

Returns the multiplicative neutral element.

source

fn from_u64(x: u64) -> Self::BaseType

Returns the element x * 1 where 1 is the multiplicative neutral element.

source

fn from_base_type(x: Self::BaseType) -> Self::BaseType

Takes as input an element of BaseType and returns the internal representation of that element in the field.

Provided Methods§

source

fn double(a: &Self::BaseType) -> Self::BaseType

Returns the double of a.

source

fn square(a: &Self::BaseType) -> Self::BaseType

Returns the multiplication of a and a.

source

fn pow<T>(a: &Self::BaseType, exponent: T) -> Self::BaseType

Object Safety§

This trait is not object safe.

Implementors§