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§
sourcefn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
fn mul(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
Returns the multiplication of a
and b
.
sourcefn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
fn sub(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
Returns the subtraction of a
and b
.
sourcefn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>
fn inv(a: &Self::BaseType) -> Result<Self::BaseType, FieldError>
Returns the multiplicative inverse of a
.
sourcefn div(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
fn div(a: &Self::BaseType, b: &Self::BaseType) -> Self::BaseType
Returns the division of a
and b
.
sourcefn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool
fn eq(a: &Self::BaseType, b: &Self::BaseType) -> bool
Returns a boolean indicating whether a
and b
are equal or not.
sourcefn from_u64(x: u64) -> Self::BaseType
fn from_u64(x: u64) -> Self::BaseType
Returns the element x * 1
where 1 is the multiplicative neutral element.
sourcefn from_base_type(x: Self::BaseType) -> Self::BaseType
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§
fn pow<T>(a: &Self::BaseType, exponent: T) -> Self::BaseTypewhere
T: IsUnsignedInteger,
Object Safety§
This trait is not object safe.