Documentation
¶
Index ¶
- func Add(a, b []field.Element) (res []field.Element)
- func EvalUnivariate(pol []field.Element, x field.Element) field.Element
- func EvaluateLagrangeAnyDomainGnark(api frontend.API, domain []frontend.Variable, x frontend.Variable) []frontend.Variable
- func EvaluateLagrangesAnyDomain(domain []field.Element, x field.Element) []field.Element
- func EvaluateUnivariateGnark(api frontend.API, pol []frontend.Variable, x frontend.Variable) frontend.Variable
- func Mul(a, b []field.Element) (res []field.Element)
- func ScalarMul(p []field.Element, x field.Element) (res []field.Element)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds two polynomials in coefficient form of possibly distinct degree. The returned slice has length = max(len(a), len(b)). The empty slice is understood as the zero polynomial and if both a and b are empty, the function returns the empty slice.
func EvalUnivariate ¶
EvalUnivariate evaluates a univariate polynomial `pol` given as a vector of coefficients. Coefficients are for increasing degree monomials: meaning that pol[0] is the constant term and pol[len(pol) - 1] is the highest degree term. The evaluation is done using the Horner method.
If the empty slice is provided, it is understood as the zero polynomial and the function returns zero.
func EvaluateLagrangeAnyDomainGnark ¶
func EvaluateLagrangeAnyDomainGnark(api frontend.API, domain []frontend.Variable, x frontend.Variable) []frontend.Variable
EvaluateLagrangeAnyDomainGnark mirrors EvaluateLagrangesAnyDomain but in a gnark circuit. The same usage precautions applies for it.
func EvaluateLagrangesAnyDomain ¶
EvaluateLagrangesAnyDomain evaluates all the Lagrange polynomials for a custom domain defined as the point point x. The function implements the naive schoolbook algorithm and is only relevant for small domains.
The function panics if provided an empty domain.
func EvaluateUnivariateGnark ¶
func EvaluateUnivariateGnark(api frontend.API, pol []frontend.Variable, x frontend.Variable) frontend.Variable
EvaluateUnivariateGnark evaluate a univariate polynomial in a gnark circuit. It mirrors EvalUnivariate.
func Mul ¶
Mul multiplies two polynomials expressed by their coefficients using the naive method and writes the result in res. `a` and `b` may have distinct degrees and the result is returned in a slice of size len(a) + len(b) - 1.
The algorithm is the schoolbook algorithm and runs in O(n^2). The usage of this usage should be reserved to reasonnably small polynomial. Otherwise, FFT methods should be preferred to this end.
The empty slice is understood as the zero polynomial. If provided on either side the function returns []field.Element{}
Types ¶
This section is empty.