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>
Sourcepub fn leading_term(&self) -> Self
pub fn leading_term(&self) -> Self
Return a new arithmetic expression that contains only the terms of highest degree (useful for interpolation at Karatsuba infinity point).
Sourcepub fn leading_term_with_degree(&self) -> (usize, Self)
pub fn leading_term_with_degree(&self) -> (usize, Self)
Same as leading_term
, but returns the total degree as the first tuple element as well.
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>
Sourcepub const fn is_composite(&self) -> bool
pub const fn is_composite(&self) -> bool
Whether expression is a composite node, and not a leaf.
Sourcepub fn optimize(&self) -> Self
pub fn optimize(&self) -> Self
Creates a new optimized expression.
Recursively rewrites expression for better evaluation performance.
Sourcepub fn linear_normal_form(&self) -> Result<LinearNormalForm<F>, Error>
pub fn linear_normal_form(&self) -> Result<LinearNormalForm<F>, Error>
Returns the normal form of an expression if it is linear.
§Throws
Error::NonLinearExpression
if the expression is not linear.
Source§impl<F: TowerField> ArithExpr<F>
impl<F: TowerField> ArithExpr<F>
pub fn binary_tower_level(&self) -> usize
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)
+=
operation. Read moreSource§impl<F: Field + DeserializeBytes> DeserializeBytes for ArithExpr<F>
impl<F: Field + DeserializeBytes> DeserializeBytes for ArithExpr<F>
fn deserialize(
read_buf: impl Buf,
mode: SerializationMode,
) -> Result<Self, SerializationError>where
Self: Sized,
Source§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)
*=
operation. Read moreSource§impl<F: Field + SerializeBytes> SerializeBytes for ArithExpr<F>
impl<F: Field + SerializeBytes> SerializeBytes for ArithExpr<F>
fn serialize( &self, write_buf: impl BufMut, mode: SerializationMode, ) -> Result<(), SerializationError>
Source§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)
-=
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
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>
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>
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