5.2 Coefficient

class Coeff( coeffInterface, coeff='0')
Specifies a coefficient
coeffInterface:
defines interface of a coefficient (see 5.1)

coeff:
string which initializes a coefficient

The class Coeff contains the following methods:

isZero( )
returns True if a coefficient is zero, otherwise returns False.

isOne( )
returns True if a coefficient is one, otherwise returns False.

setZero( )
zeroizes a coefficient.

setOne( )
makes a coefficient equal to one.

gcd( coeff)
returns GCD of a coefficient and coefficient coeff.

The coefficients must have the same interface.

diff( par, deg=1)
Returns the derivative of a coefficient with respect to the parameter of index par raised to the power deg.

The class Coeff can be an argument of the following functions:

str( coeff)
returns representation in the form of coefficient string coeff in accordance to the type of system 3.

The Python command print works similarly.

+, -, *, /( coeff1, coeff2)
These operations return, respectively, the sum, the difference, the product and the quotient of coefficients. To perform the division coeff2 must divide coeff1.

The coefficients must have the same interface.

-( coeff)
returns negative coefficient.

+=, -=, *=, /=( coeff1, coeff2)
These operations assign the sum, the difference, the product and the quotient of coefficients. For the division coeff2 must divide coeff1.

The coefficients must have the same interface.

A coefficient can be also used in logical expressions. Zero coefficient yields False in logical expressions, and other coefficients yield True.

A small illustrative program of manipulation with coefficients:

import ginv

st = ginv.SystemType("Polynomial")
ic = ginv.CoeffInterface("GmpZ", st)
print ic.type()

print ginv.Coeff(ic, "12221965").gcd(ginv.Coeff(ic, "196196196"))
print ginv.Coeff(ic, "121965") + ginv.Coeff(ic, "196196196")
As a result, the following will be printed out:
GmpZ
7
196318161