Documentation ¶
Overview ¶
Package polynomial provides representations of polynomials over the scalars of a group.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LagrangePolynomial ¶
type LagrangePolynomial struct {
// contains filtered or unexported fields
}
LagrangePolynomial stores a Lagrange polynomial over the set of scalars of a group.
func NewLagrangePolynomial ¶
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 (LagrangePolynomial) Degree ¶
func (l LagrangePolynomial) Degree() int
type Polynomial ¶
type Polynomial struct {
// contains filtered or unexported fields
}
Polynomial stores a polynomial over the set of scalars of a group.
func New ¶
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 (Polynomial) Degree ¶
func (p Polynomial) Degree() int