common

package
v0.0.2-0...-db6250e Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: CC0-1.0, CC0-1.0, CC0-1.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

Add returns the sum f + g, where f is the polynomial defined by the parallel slices esf and csf of exponents and coefficients, and similarly g is defined by esg and csg. The sum is returned as two parallel slices of exponents and coefficients.

func AreEqual

AreEqual returns true iff the polynomials f and g are equal, where f is described by the parallel slices of exponents esf and coefficients csf, and g is described by the parallel slices of exponents esg and coefficients csg. Assumes that the slices are sorted in increasing exponent order.

func Basis

Basis returns two parallel slices of exponents and coefficients corresponding to the variables x_0,...,x_k of the polynomial ring. The exponent helper eh must satisfy one of the following interfaces:

type Basiser interface {
	Basis() []unwrappedexponents.Interface // Basis returns a slice of
	   slices of unwrapped exponents corresponding to the variables
	   x_0,...,x_{rk-1} in the polynomial ring, where rk is the rank of
	   the exponent universe.
}

type NthBasisElementer interface {
	NthBasisElement(n int) (unwrappedexponents.Interface, error)
		// NthBasisElement returns a slice of unwrapped exponents
		   corresponding to the n-th variable x_n in the polynomial
		   ring. Here variables are indexed from 0 to rk - 1
		   (inclusive), where rk is the rank of the exponent universe.
}

func CmpLeadingMonomial

func CmpLeadingMonomial(esf exponents.Interface, esg exponents.Interface) (int, error)

CmpLeadingMonomial returns -1 if LM(f) < LM(g), 0 if LM(f) = LM(g), and +1 if LM(f) > LM(g), were LM denotes the leading monomial. The exponents of the polynomial f (and, respectively, g) are given by the slice of exponents esf (resp. esg), which are assumed to be sorted in increasing exponent order. It returns an error if f = 0 or g = 0, in which case LM(f) or LM(g) is not well-defined, or if the parents of the monomials do not agree.

func Derivative

Derivative returns the formal partial derivative df/dx_k of the polynomial f, where the variables x_i are indexed from 0. Here f is the polynomial defined by the parallel slices es and cs of exponents and coefficients. The partial derivative is returned as two parallel slices of exponents and coefficients. The exponent helper eh must satisfy one of the following two interfaces:

type Derivativer interface {
	Derivative(k int, es exponents.Interface,
		cs coefficients.Interface, ch coefficients.Helper)
		(unwrappedexponents.Interface, unwrappedcoefficients.Interface,
		 error) // Derivative returns the formal partial derivative
		   df/dx_k of the polynomial f, where the variables x_i are
		   indexed from 0. Here f is the polynomial defined by the
		   parallel slices es and cs of exponents and coefficients. The
		   partial derivative is returned as two parallel slices of
		   exponents and coefficients.
}

type NthDerivativer interface {
	NthDerivative(n int, k int, es exponents.Interface,
		cs coefficients.Interface, ch coefficients.Helper)
		(unwrappedexponents.Interface, unwrappedcoefficients.Interface,
		 error) // NthDerivative returns the n-th formal partial
		   derivative d^nf/dx_k^n of the polynomial f, where the
		   variables x_i are indexed from 0. Here f is the polynomial
		   defined by the parallel slices es and cs of exponents and
		   coefficients. The partial derivative is returned as two
		   parallel slices of exponents and coefficients.
}

func FromParallelSlices

FromParallelSlices returns parallel slices of exponents and coefficients, where the exponents are from the slice es, and the coefficients from the slice cs. The returned slices of exponents and coefficients will be parallel sorted.

func Hash

Hash returns a hash value for the given parallel slices of exponents and coefficients.

func IsConstant

IsConstant returns true iff the parallel slices of exponents es and coefficients cs describe a constant polynomial. If true, also returns the constant.

func IsMonic

func IsMonic(cs coefficients.Interface) (bool, error)

IsMonic returns true iff the slice of coefficients cs describe a monic polynomial f (that is, if the leading coefficient of f is 1). Assumes that the slice is sorted in increasing exponent order.

func IsMonomial

func IsMonomial(cs coefficients.Interface) (bool, error)

IsMonomial returns true iff the slice of coefficients cs correspond to a monomial (that is, x^m for some m in the exponent monoid).

func IsNthBasisElement

func IsNthBasisElement(n int, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (bool, error)

IsNthBasisElement returns true iff the parallel slices of exponents es and coefficients cs correspond to the n-th variable x_n of the polynomial ring. Here variables are indexed from 0 to rk - 1 (inclusive), where rk is the rank. If the exponent helper eh satisfies the interface:

type IsNthBasisElementer interface {
	IsNthBasisElement(n int, S unwrappedexponents.Interface) (bool,
		 error) // IsNthBasisElement returns true iff the slice of
			 unwrapped exponents S corresponds to the n-th variable x_n
			 in the polynomial ring. Here variables are indexed from 0
			 to rk - 1 (inclusive), where rk is the rank of the
			 exponent universe.
}

then eh's IsNthBasisElement method will be called. Otherwise, the exponent helper eh must satisfy either the Basiser or NthBasisElementer interfaces, as described in Basis.

func IsOne

IsOne returns true iff the parallel slices of exponents es and coefficients cs correspond to the polynomial 1.

func Multiply

Multiply returns the product f * g, where f is the polynomial defined by the parallel slices esf and csf of exponents and coefficients, and similarly g is defined by esg and csg. The product is returned as two parallel slices of exponents and coefficients.

func Negate

Negate returns the negation -f, where f is the polynomial defined by the slice cs of coefficients. The resulting coefficients will be returned.

func NthBasisElement

NthBasisElement returns the parallel slices of exponents and coefficients corresponding to the n-th variable x_n of the polynomial ring. Here variables are indexed from 0 to rk - 1 (inclusive), where rk is the rank. The exponent helper eh must satisfy either the Basiser or NthBasisElementer interfaces, as described in Basis.

func NthDerivative

NthDerivative returns the n-th formal partial derivative d^nf/dx_k^n of the polynomial f, where the variables x_i are indexed from 0. Here f is the polynomial defined by the parallel slices es and cs of exponents and coefficients. The partial derivative is returned as two parallel slices of exponents and coefficients. The exponent helper eh must satisfy either the Derivativer or NthDerivativer interfaces, as described in Derivative.

func NthMonomial

NthMonomial returns parallel slices of exponents and coefficients describing the N-th monomial x^k in the polynomial f, where the exponents of f are described by the given slice of exponents es.

func NthTerm

NthTerm returns parallel slices of exponents and coefficients describing the N-th term c * x^k in the polynomial f, where f is described by the given parallel slices of exponents es and coefficients cs.

func Power

Power returns f^k. Here f is the polynomial defined by the parallel slices es and cs of exponents and coefficients. The power is returned as two parallel slices of exponents and coefficients.

func PowerInt64

PowerInt64 returns f^k. Here f is the polynomial defined by the parallel slices es and cs of exponents and coefficients. The power is returned as two parallel slices of exponents and coefficients.

func ScalarMultiplyByCoefficient

ScalarMultiplyByCoefficient returns a * f, where a is an element in the coefficient ring and f is the polynomial defined by the parallel slices es and cs of exponents and coefficients. The result is returned as two parallel slices of exponents and coefficients.

func ScalarMultiplyByInteger

ScalarMultiplyByInteger returns n * f, where this is defined to be f + ... + f (n times) if n is positive, -f - ... - f (|n| times) if n is negative, and 0 if n is zero. Here f is the polynomial defined by the parallel slices es and cs of exponents and coefficients. The result is returned as two parallel slices of exponents and coefficients.

func Subtract

Subtract returns the difference f - g, where f is the polynomial defined by the parallel slices esf and csf of exponents and coefficients, and similarly g is defined by esg and csg. The difference is returned as two parallel slices of exponents and coefficients.

func Sum

Sum returns the sum of the polynomials described by the parallel slices Es and Cs, where the i-th entry Es[i] and Cs[i] in each slice are parallel slices describing the exponents and coefficients, respectively, of a polynomial. The sum is returned as two parallel slices of exponents and coefficients. The slices Es and Cs are assumed to be of the same length.

func ToMonomial

ToMonomial returns parallel slices of exponents and coefficients describing the monomial x^k.

func ToTerm

ToTerm returns parallel slices of exponents and coefficients describing the term c * x^k, where c is an element in the coefficient ring.

Types

type BinaryOperation

BinaryOperation defines a binary operation on polynomials f and g, which returns exponents and coefficients defining a new polynomial. Here f is represented by parallel slices of exponents esf and coefficients csf, and similarly for g.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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