Skip to main content

M31

Struct M31 

Source
#[repr(transparent)]
pub struct M31(pub u32);

Tuple Fields§

§0: u32

Implementations§

Source§

impl M31

Source

pub fn partial_reduce(val: u32) -> Self

Returns val % P when val is in the range [0, 2P).

use stwo::core::fields::m31::{M31, P};

let val = 2 * P - 19;
assert_eq!(M31::partial_reduce(val), M31::from(P - 19));
Source

pub const fn reduce(val: u64) -> Self

Returns val % P when val is in the range [0, P^2).

use stwo::core::fields::m31::{M31, P};

let val = (P as u64).pow(2) - 19;
assert_eq!(M31::reduce(val), M31::from(P - 19));
Source

pub const fn from_u32_unchecked(arg: u32) -> Self

Source

pub fn inverse(&self) -> Self

Trait Implementations§

Source§

impl Add for M31

Source§

type Output = M31

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<CM31> for M31

Source§

type Output = CM31

The resulting type after applying the + operator.
Source§

fn add(self, rhs: CM31) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<M31> for CM31

Source§

type Output = CM31

The resulting type after applying the + operator.
Source§

fn add(self, rhs: M31) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<M31> for QM31

Source§

type Output = QM31

The resulting type after applying the + operator.
Source§

fn add(self, rhs: M31) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<QM31> for M31

Source§

type Output = QM31

The resulting type after applying the + operator.
Source§

fn add(self, rhs: QM31) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for M31

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl AddAssign<M31> for CM31

Source§

fn add_assign(&mut self, rhs: M31)

Performs the += operation. Read more
Source§

impl AddAssign<M31> for QM31

Source§

fn add_assign(&mut self, rhs: M31)

Performs the += operation. Read more
Source§

impl Clone for M31

Source§

fn clone(&self) -> M31

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComplexConjugate for M31

Source§

fn complex_conjugate(&self) -> Self

Example Read more
Source§

impl Copy for M31

Source§

impl Debug for M31

Source§

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

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

impl Default for M31

Source§

fn default() -> M31

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for M31

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 Display for M31

Source§

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

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

impl Distribution<M31> for Standard

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> M31

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl Div for M31

Source§

type Output = M31

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<CM31> for M31

Source§

type Output = CM31

The resulting type after applying the / operator.
Source§

fn div(self, rhs: CM31) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<M31> for CM31

Source§

type Output = CM31

The resulting type after applying the / operator.
Source§

fn div(self, rhs: M31) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<M31> for QM31

Source§

type Output = QM31

The resulting type after applying the / operator.
Source§

fn div(self, rhs: M31) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<QM31> for M31

Source§

type Output = QM31

The resulting type after applying the / operator.
Source§

fn div(self, rhs: QM31) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign for M31

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl DivAssign<M31> for CM31

Source§

fn div_assign(&mut self, rhs: M31)

Performs the /= operation. Read more
Source§

impl DivAssign<M31> for QM31

Source§

fn div_assign(&mut self, rhs: M31)

Performs the /= operation. Read more
Source§

impl Eq for M31

Source§

impl ExtensionOf<M31> for CM31

Source§

impl ExtensionOf<M31> for QM31

Source§

impl Field for M31

Source§

fn double(&self) -> Self

Source§

impl FieldExpOps for M31

Source§

fn inverse(&self) -> Self

use num_traits::One;
use stwo::core::fields::m31::BaseField;
use stwo::core::fields::FieldExpOps;

let v = BaseField::from(19);
assert_eq!(v.inverse() * v, BaseField::one());
Source§

fn square(&self) -> Self

Source§

fn pow(&self, exp: u128) -> Self

Source§

fn batch_inverse(column: &[Self]) -> Vec<Self>

Source§

impl From<M31> for CM31

Source§

fn from(x: M31) -> Self

Converts to this type from the input type.
Source§

impl From<M31> for QM31

Source§

fn from(x: M31) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for M31

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for M31

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for M31

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl Hash for M31

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 Mul for M31

Source§

type Output = M31

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<CM31> for M31

Source§

type Output = CM31

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: CM31) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<M31> for CM31

Source§

type Output = CM31

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: M31) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<M31> for QM31

Source§

type Output = QM31

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: M31) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<QM31> for M31

Source§

type Output = QM31

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: QM31) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign for M31

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl MulAssign<M31> for CM31

Source§

fn mul_assign(&mut self, rhs: M31)

Performs the *= operation. Read more
Source§

impl MulAssign<M31> for QM31

Source§

fn mul_assign(&mut self, rhs: M31)

Performs the *= operation. Read more
Source§

impl Neg for M31

Source§

type Output = M31

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Num for M31

Source§

type FromStrRadixErr = Box<dyn Error>

Source§

fn from_str_radix( _str: &str, _radix: u32, ) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Source§

impl One for M31

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl Ord for M31

Source§

fn cmp(&self, other: &M31) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for M31

Source§

fn eq(&self, other: &M31) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 PartialOrd for M31

Source§

fn partial_cmp(&self, other: &M31) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Pod for M31

Source§

impl Product for M31

Source§

fn product<I>(iter: I) -> Self
where I: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<'a> Product<&'a M31> for M31

Source§

fn product<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl Rem for M31

Source§

type Output = M31

The resulting type after applying the % operator.
Source§

fn rem(self, _rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<M31> for CM31

Source§

type Output = CM31

The resulting type after applying the % operator.
Source§

fn rem(self, _rhs: M31) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<M31> for QM31

Source§

type Output = QM31

The resulting type after applying the % operator.
Source§

fn rem(self, _rhs: M31) -> Self::Output

Performs the % operation. Read more
Source§

impl RemAssign for M31

Source§

fn rem_assign(&mut self, _rhs: Self)

Performs the %= operation. Read more
Source§

impl RemAssign<M31> for CM31

Source§

fn rem_assign(&mut self, _rhs: M31)

Performs the %= operation. Read more
Source§

impl RemAssign<M31> for QM31

Source§

fn rem_assign(&mut self, _rhs: M31)

Performs the %= operation. Read more
Source§

impl Serialize for M31

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 StructuralPartialEq for M31

Source§

impl Sub for M31

Source§

type Output = M31

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<CM31> for M31

Source§

type Output = CM31

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: CM31) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<M31> for CM31

Source§

type Output = CM31

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: M31) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<M31> for QM31

Source§

type Output = QM31

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: M31) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<QM31> for M31

Source§

type Output = QM31

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: QM31) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for M31

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl SubAssign<M31> for CM31

Source§

fn sub_assign(&mut self, rhs: M31)

Performs the -= operation. Read more
Source§

impl SubAssign<M31> for QM31

Source§

fn sub_assign(&mut self, rhs: M31)

Performs the -= operation. Read more
Source§

impl Sum for M31

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a> Sum<&'a M31> for M31

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TryInto<M31> for CM31

Source§

type Error = ()

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

fn try_into(self) -> Result<M31, Self::Error>

Performs the conversion.
Source§

impl TryInto<M31> for QM31

Source§

type Error = ()

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

fn try_into(self) -> Result<M31, Self::Error>

Performs the conversion.
Source§

impl Zero for M31

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Zeroable for M31

Source§

fn zeroed() -> Self

Auto Trait Implementations§

§

impl Freeze for M31

§

impl RefUnwindSafe for M31

§

impl Send for M31

§

impl Sync for M31

§

impl Unpin for M31

§

impl UnsafeUnpin for M31

§

impl UnwindSafe for M31

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> AnyBitPattern for T
where T: Pod,

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

Source§

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

Source§

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

Compare self to key and return true if they are equal.
Source§

impl<F> ExtensionOf<F> for F
where F: Field,

Source§

const EXTENSION_DEGREE: usize = const EXTENSION_DEGREE: usize = 1;

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> NumAssign for T
where T: Num + NumAssignOps,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> UniformRand for T

Source§

fn rand<R>(rng: &mut R) -> T
where R: Rng + ?Sized,

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more