Neg returns the negation of the given variable.
(i frontend.Variable)
| 94 | |
| 95 | // Neg returns the negation of the given variable. |
| 96 | func (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. |
| 111 | func (builder *builder) Mul(i1, i2 frontend.Variable, in ...frontend.Variable) frontend.Variable { |
no test coverage detected