func LagrangeBase(jth uint, xi []group.Scalar, x group.Scalar) group.Scalar
LagrangeBase returns the j-th Lagrange polynomial base evaluated at x. Thus, L_j(x) = \prod (x - x[i]) / (x[j] - x[i]) for 0 <= i < k, and i != j.
LagrangePolynomial stores a Lagrange polynomial over the set of scalars of a group.
type LagrangePolynomial struct {
// contains filtered or unexported fields
}
func NewLagrangePolynomial(x, y []group.Scalar) (l LagrangePolynomial)
NewLagrangePolynomial creates a polynomial in Lagrange basis given a list of nodes (x) and values (y), such that:
p(x) = \sum_i^k y[i] L_j(x), where k is the degree of the polynomial, L_j(x) = \prod_i^k (x-x[i])/(x[j]-x[i]), y[i] = p(x[i]), and all x[i] are different.
It panics if one of these conditions does not hold.
The zero polynomial has degree equal to -1 and can be instantiated passing (nil,nil) to NewLagrangePolynomial.
func (l LagrangePolynomial) Degree() int
func (l LagrangePolynomial) Evaluate(x group.Scalar) group.Scalar
Polynomial stores a polynomial over the set of scalars of a group.
type Polynomial struct {
// contains filtered or unexported fields
}
func New(coeffs []group.Scalar) (p Polynomial)
New creates a new polynomial given its coefficients in ascending order. Thus,
p(x) = \sum_i^k c[i] x^i,
where k = len(c)-1 is the degree of the polynomial.
The zero polynomial has degree equal to -1 and can be instantiated passing nil to New.
func (p Polynomial) Degree() int
func (p Polynomial) Evaluate(x group.Scalar) group.Scalar