pub enum ArithExpr<F: Field> {
Const(F),
Var(usize),
Add(Box<ArithExpr<F>>, Box<ArithExpr<F>>),
Mul(Box<ArithExpr<F>>, Box<ArithExpr<F>>),
Pow(Box<ArithExpr<F>>, u64),
}
Expand description
Arithmetic expressions that can be evaluated symbolically.
Arithmetic expressions are trees, where the leaves are either constants or variables, and the non-leaf nodes are arithmetic operations, such as addition, multiplication, etc. They are specific representations of multivariate polynomials.
Variants§
Const(F)
Var(usize)
Add(Box<ArithExpr<F>>, Box<ArithExpr<F>>)
Mul(Box<ArithExpr<F>>, Box<ArithExpr<F>>)
Pow(Box<ArithExpr<F>>, u64)
Implementations§
Source§impl<F: Field> ArithExpr<F>
impl<F: Field> ArithExpr<F>
pub fn pow(self, exp: u64) -> Self
pub const fn zero() -> Self
pub const fn one() -> Self
Sourcepub fn remap_vars(self, indices: &[usize]) -> Result<Self, Error>
pub fn remap_vars(self, indices: &[usize]) -> Result<Self, Error>
Creates a new expression with the variable indices remapped.
This recursively replaces the variable sub-expressions with an index i
with the variable
indices[i]
.
§Throws
Error::IncorrectArgumentLength
if indices has length less than the current number of variables
pub fn convert_field<FTgt: Field + From<F>>(&self) -> ArithExpr<FTgt>
pub fn try_convert_field<FTgt: Field + TryFrom<F>>( &self, ) -> Result<ArithExpr<FTgt>, <FTgt as TryFrom<F>>::Error>
Trait Implementations§
Source§impl<F> AddAssign for ArithExpr<F>where
F: Field,
impl<F> AddAssign for ArithExpr<F>where
F: Field,
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moreSource§impl<F> MulAssign for ArithExpr<F>where
F: Field,
impl<F> MulAssign for ArithExpr<F>where
F: Field,
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moreSource§impl<F> SubAssign for ArithExpr<F>where
F: Field,
impl<F> SubAssign for ArithExpr<F>where
F: Field,
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl<F: Eq + Field> Eq for ArithExpr<F>
impl<F: Field> StructuralPartialEq for ArithExpr<F>
Auto Trait Implementations§
impl<F> Freeze for ArithExpr<F>
impl<F> RefUnwindSafe for ArithExpr<F>
impl<F> Send for ArithExpr<F>
impl<F> Sync for ArithExpr<F>
impl<F> Unpin for ArithExpr<F>
impl<F> UnwindSafe for ArithExpr<F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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