polynomial

package
v0.0.0-...-ac9c40d Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

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

func LagrangeBase

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.

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

func (LagrangePolynomial) Evaluate

func (l LagrangePolynomial) Evaluate(x group.Scalar) group.Scalar

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

func (Polynomial) Evaluate

func (p Polynomial) Evaluate(x group.Scalar) group.Scalar

Jump to

Keyboard shortcuts

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