MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / Neg

Method Neg

ecgo/builder/api.go:96–108  ·  view source on GitHub ↗

Neg returns the negation of the given variable.

(i frontend.Variable)

Source from the content-addressed store, hash-verified

94
95// Neg returns the negation of the given variable.
96func (builder *builder) Neg(i frontend.Variable) frontend.Variable {
97 v := builder.toVariableId(i)
98 if c, ok := builder.constantValue(v); ok {
99 return builder.toVariable(builder.field.Neg(c))
100 }
101 coef := []constraint.Element{builder.field.Neg(builder.tOne)}
102 builder.instructions = append(builder.instructions, irsource.Instruction{
103 Type: irsource.LinComb,
104 Inputs: []int{v},
105 LinCombCoef: coef,
106 })
107 return builder.addVar()
108}
109
110// Mul computes the product of the given variables.
111func (builder *builder) Mul(i1, i2 frontend.Variable, in ...frontend.Variable) frontend.Variable {

Callers 3

andFunction · 0.45
andFunction · 0.45
addMethod · 0.45

Calls 4

toVariableIdMethod · 0.95
constantValueMethod · 0.95
toVariableMethod · 0.95
addVarMethod · 0.95

Tested by

no test coverage detected