Documentation
¶
Overview ¶
An expression supporting quadratic terms, implemented based on gnark `frontend/internal/expr`.
Index ¶
- type Expression
- func (e Expression) Clone() Expression
- func (e Expression) CountOfDegrees() (int, int, int)
- func (e Expression) Degree() int
- func (e Expression) Equal(o Expression) bool
- func (e Expression) EqualI(o utils.Hashable) bool
- func (e Expression) HashCode() uint64
- func (e Expression) IsConstant() bool
- func (e Expression) Len() int
- func (e Expression) Less(i, j int) bool
- func (e Expression) Swap(i, j int)
- func (e Expression) ToBigIntRegular(*big.Int) *big.Int
- type Term
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expression ¶
type Expression []Term
func NewConstantExpression ¶
func NewConstantExpression(c constraint.Element) Expression
NewConstantExpression returns c
func NewLinearExpression ¶
func NewLinearExpression(v int, c constraint.Element) Expression
NewLinearExpression returns c * v
func NewQuadraticExpression ¶
func NewQuadraticExpression(v0, v1 int, c constraint.Element) Expression
NewQuadraticExpression returns c * v0 * v1
func (Expression) Clone ¶
func (e Expression) Clone() Expression
func (Expression) CountOfDegrees ¶
func (e Expression) CountOfDegrees() (int, int, int)
CountOfDegrees returns the number of terms of each degree
func (Expression) Degree ¶
func (e Expression) Degree() int
Degree returns the degree of the polynomial
func (Expression) Equal ¶
func (e Expression) Equal(o Expression) bool
Equals returns true if both SORTED expressions are the same
pre conditions: l and o are sorted
func (Expression) EqualI ¶
func (e Expression) EqualI(o utils.Hashable) bool
EqualI is similar to Equal, but o is utils.Hashable. Then it can be saved in a utils.Map
func (Expression) HashCode ¶
func (e Expression) HashCode() uint64
HashCode returns a fast-to-compute but NOT collision resistant hash code identifier for the linear expression
requires sorted
func (Expression) IsConstant ¶
func (e Expression) IsConstant() bool
func (Expression) Len ¶
func (e Expression) Len() int
Len return the length of the Variable (implements Sort interface)
func (Expression) Less ¶
func (e Expression) Less(i, j int) bool
Less returns true if variableID for term at i is less than variableID for term at j (implements Sort interface)
func (Expression) Swap ¶
func (e Expression) Swap(i, j int)
Swap swaps terms in the Variable (implements Sort interface)
func (Expression) ToBigIntRegular ¶
func (e Expression) ToBigIntRegular(*big.Int) *big.Int
ToBigIntRegular implements gnark toBigIntInterface interface Actually it's impossible to convert an Expression to big.Int, but sometimes it requires such evaluation (like in gnark utils.FromInterface). So a fake implementation is created to provide better instructions for users
type Term ¶
type Term struct {
// if vid1 is 0, it means linear term.
// if both vid are 0, it means constant
VID0 int
VID1 int
Coeff constraint.Element
}
func (*Term) SetCoeff ¶
func (t *Term) SetCoeff(c constraint.Element)
func (Term) ToBigIntRegular ¶
ToBigIntRegular implements gnark toBigIntInterface interface Actually it's impossible to convert a Term to big.Int, but sometimes it requires such evaluation (like in gnark utils.FromInterface). So a fake implementation is created to provide better instructions for users