purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
purify::ExprBuilder Class Reference

Small runtime builder that flattens affine combinations into one expression. More...

#include <expr.hpp>

Public Member Functions

ExprBuilderreserve (std::size_t terms)
 Reserves storage for approximately terms linear slots.
 
ExprBuilderadd (const FieldElement &value)
 Adds a constant field term to the pending affine expression.
 
ExprBuilderadd (std::int64_t value)
 Adds an integer constant term to the pending affine expression.
 
ExprBuilderadd_term (Symbol symbol, const FieldElement &scale)
 Adds one scaled symbolic variable term.
 
ExprBuilderadd (const Expr &expr)
 Adds an existing expression with implicit coefficient one.
 
ExprBuildersubtract (const Expr &expr)
 Subtracts an existing expression with implicit coefficient minus one.
 
ExprBuilderadd_scaled (const Expr &expr, const FieldElement &scale)
 Adds an existing expression scaled by a field element.
 
ExprBuilderadd_scaled (const Expr &expr, std::int64_t scale)
 Adds an existing expression scaled by an integer constant.
 
Expr build ()
 Materializes the flattened affine expression.
 

Static Public Member Functions

static ExprBuilder reserved (std::size_t terms)
 Returns a builder with storage reserved for approximately terms linear slots.
 

Detailed Description

This avoids repeated intermediate Expr allocations in gadgets that know they are constructing a linear combination of existing expressions.

Definition at line 170 of file expr.hpp.

Member Function Documentation

◆ add() [1/3]

ExprBuilder & purify::ExprBuilder::add ( const Expr expr)

Definition at line 187 of file expr.cpp.

References purify::Expr::constant(), and purify::Expr::linear().

◆ add() [2/3]

◆ add() [3/3]

ExprBuilder & purify::ExprBuilder::add ( std::int64_t  value)

Definition at line 176 of file expr.cpp.

References add(), and purify::FieldElement::from_int().

◆ add_scaled() [1/2]

◆ add_scaled() [2/2]

ExprBuilder & purify::ExprBuilder::add_scaled ( const Expr expr,
std::int64_t  scale 
)

Definition at line 238 of file expr.cpp.

References add_scaled(), and purify::FieldElement::from_int().

◆ add_term()

ExprBuilder & purify::ExprBuilder::add_term ( Symbol  symbol,
const FieldElement scale 
)

Definition at line 180 of file expr.cpp.

References purify::FieldElement::is_zero().

◆ build()

◆ reserve()

ExprBuilder & purify::ExprBuilder::reserve ( std::size_t  terms)

Definition at line 166 of file expr.cpp.

◆ reserved()

ExprBuilder purify::ExprBuilder::reserved ( std::size_t  terms)
static

◆ subtract()


The documentation for this class was generated from the following files: