Documentation ¶
Index ¶
- func Add(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, ...) (exponents.Interface, coefficients.Interface, error)
- func AreEqual(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, ...) (bool, error)
- func Basis(eh exponents.Helper, ch coefficients.Helper) ([]exponents.Interface, []coefficients.Interface, error)
- func CmpLeadingMonomial(esf exponents.Interface, esg exponents.Interface) (int, error)
- func Derivative(k int, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ...) (exponents.Interface, coefficients.Interface, error)
- func FromParallelSlices(es slice.Interface, cs slice.Interface, eh exponents.Helper, ...) (exponents.Interface, coefficients.Interface, error)
- func Hash(es exponents.Interface, cs coefficients.Interface) hash.Value
- func IsConstant(es exponents.Interface, cs coefficients.Interface) (bool, object.Element, error)
- func IsMonic(cs coefficients.Interface) (bool, error)
- func IsMonomial(cs coefficients.Interface) (bool, error)
- func IsNthBasisElement(n int, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ...) (bool, error)
- func IsOne(es exponents.Interface, cs coefficients.Interface) (bool, error)
- func Multiply(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, ...) (exponents.Interface, coefficients.Interface, error)
- func Negate(cs coefficients.Interface, ch coefficients.Helper) (coefficients.Interface, error)
- func NthBasisElement(n int, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
- func NthDerivative(n int, k int, es exponents.Interface, cs coefficients.Interface, ...) (exponents.Interface, coefficients.Interface, error)
- func NthMonomial(N int, es exponents.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
- func NthTerm(N int, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ...) (exponents.Interface, coefficients.Interface, error)
- func Power(es exponents.Interface, cs coefficients.Interface, k *integer.Element, ...) (exponents.Interface, coefficients.Interface, error)
- func PowerInt64(es exponents.Interface, cs coefficients.Interface, k int64, ...) (exponents.Interface, coefficients.Interface, error)
- func ScalarMultiplyByCoefficient(a object.Element, es exponents.Interface, cs coefficients.Interface, ...) (exponents.Interface, coefficients.Interface, error)
- func ScalarMultiplyByInteger(n *integer.Element, es exponents.Interface, cs coefficients.Interface, ...) (exponents.Interface, coefficients.Interface, error)
- func Subtract(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, ...) (exponents.Interface, coefficients.Interface, error)
- func Sum(Es []exponents.Interface, Cs []coefficients.Interface, eh exponents.Helper, ...) (exponents.Interface, coefficients.Interface, error)
- func ToMonomial(k object.Element, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
- func ToTerm(k object.Element, c object.Element, eh exponents.Helper, ...) (exponents.Interface, coefficients.Interface, error)
- type BinaryOperation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, csg coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func AreEqual(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, csg coefficients.Interface) (bool, error)
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 ¶
func Basis(eh exponents.Helper, ch coefficients.Helper) ([]exponents.Interface, []coefficients.Interface, error)
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 ¶
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 ¶
func Derivative(k int, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.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. 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 ¶
func FromParallelSlices(es slice.Interface, cs slice.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 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 ¶
func Multiply(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, csg coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func Negate(cs coefficients.Interface, ch coefficients.Helper) (coefficients.Interface, error)
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 ¶
func NthBasisElement(n int, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func NthDerivative(n int, k int, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.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. The exponent helper eh must satisfy either the Derivativer or NthDerivativer interfaces, as described in Derivative.
func NthMonomial ¶
func NthMonomial(N int, es exponents.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func NthTerm(N int, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func Power(es exponents.Interface, cs coefficients.Interface, k *integer.Element, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func PowerInt64(es exponents.Interface, cs coefficients.Interface, k int64, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func ScalarMultiplyByCoefficient(a object.Element, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func ScalarMultiplyByInteger(n *integer.Element, es exponents.Interface, cs coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func Subtract(esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, csg coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func Sum(Es []exponents.Interface, Cs []coefficients.Interface, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
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 ¶
func ToMonomial(k object.Element, eh exponents.Helper, ch coefficients.Helper) (exponents.Interface, coefficients.Interface, error)
ToMonomial returns parallel slices of exponents and coefficients describing the monomial x^k.
Types ¶
type BinaryOperation ¶
type BinaryOperation func( esf exponents.Interface, csf coefficients.Interface, esg exponents.Interface, csg coefficients.Interface, eh exponents.Helper, ch coefficients.Helper, ) (exponents.Interface, coefficients.Interface, error)
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.