poly

package
v0.0.0-...-18b2cfc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b []field.Element) (res []field.Element)

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

func EvalUnivariate(pol []field.Element, x field.Element) field.Element

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

func EvaluateLagrangesAnyDomain(domain []field.Element, x field.Element) []field.Element

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

func Mul(a, b []field.Element) (res []field.Element)

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{}

func ScalarMul

func ScalarMul(p []field.Element, x field.Element) (res []field.Element)

ScalarMul multiplies a polynomials in coefficient form by a scalar.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL