| Home | Trees | Index | Help |
|
|---|
| Module pypol :: Class Polynomial |
|
object--+ |list--+ | Polynomial
Provide a class representing a polynomial intended as a list of monomials. Inherits from the list built-in class and provide methods that implement the most common operations: addition, subtraction, multiplication, divison and power.
Example:>>> print Polynomial([Monomial(2, x=2), Monomial(-1, y=1)]) 2 2 x - y
| Method Summary | |
|---|---|
Build a polynomial given a list of monomials. | |
__add__(self,
my_polynomial)
| |
Division without rest. | |
__divmod__(self,
my_polynomial)
| |
__eq__(self,
my_polynomial)
| |
In-place addition. | |
In-place multiplication. | |
Division rest. | |
__mul__(self,
my_polynomial)
| |
Determine if two polynomials aren't equal. | |
Change the sign to all monomials in the polynomial. | |
Raise the polynomial to the power n. | |
__radd__(self,
my_polynomial)
| |
__rdiv__(self,
my_polynomial)
| |
__rdivmod__(self,
my_polynomial)
| |
Return a value that, passed to eval(), should return a Polynomial instance equal to self. | |
__rmod__(self,
my_polynomial)
| |
__rmul__(self,
my_polynomial)
| |
__rsub__(self,
my_polynomial)
| |
Print the polynomial in a human-readable manner. | |
__sub__(self,
my_polynomial)
| |
Division with __future__.division | |
Check if the second term of an operation is a Polynomial | |
Resolve the polynomial using it as a function P(x, y, ...). | |
Generate a polynomial instance with given coefficients and specified unknown (Class method) | |
Simplify the polynomial: sum similar monomials and delete zero-coefficient monomials. | |
| Inherited from list | |
x.__contains__(y) <==> y in x | |
x.__delitem__(y) <==> del x[y] | |
Use of negative indices is not supported. | |
x.__ge__(y) <==> x>=y | |
x.__getattribute__('name') <==> x.name | |
x.__getitem__(y) <==> x[y] | |
Use of negative indices is not supported. | |
x.__gt__(y) <==> x>y | |
x.__hash__() <==> hash(x) | |
x.__iter__() <==> iter(x) | |
x.__le__(y) <==> x<=y | |
x.__len__() <==> len(x) | |
x.__lt__(y) <==> x<y | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
L.__reversed__() -- return a reverse iterator over the list | |
x.__setitem__(i, y) <==> x[i]=y | |
Use of negative indices is not supported. | |
L.append(object) -- append object to end | |
L.count(value) -> integer -- return number of occurrences of value | |
L.extend(iterable) -- extend list by appending elements from the iterable | |
L.index(value, [start, [stop]]) -> integer -- return first index of value | |
L.insert(index, object) -- insert object before index | |
L.pop([index]) -> item -- remove and return item at index (default last) | |
L.remove(value) -- remove first occurrence of value | |
L.reverse() -- reverse *IN PLACE* | |
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 | |
| Inherited from object | |
x.__delattr__('name') <==> del x.name | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
| Property Summary | |
|---|---|
degree: Return polynomial's degree. | |
| Instance Method Details |
|---|
__init__(self,
monomials)
|
__div__(self, my_polynomial)Division without rest. See also method __divmod__. |
__iadd__(self, my_polynomial)In-place addition. See also method __add__.
|
__imul__(self, my_polynomial)In-place multiplication. See also method __mul__.
|
__mod__(self, my_polynomial)Division rest. See also method __divmod__. |
__ne__(self, my_polynomial)Determine if two polynomials aren't equal.
|
__neg__(self)Change the sign to all monomials in the polynomial. Example:>>> print -Polynomial([Monomial(2, x=2), Monomial(-1, y=1)]) 2 - 2 x + y |
__pow__(self, n)Raise the polynomial to the power n. Example:>>> print Polynomial([Monomial(2, x=2), Monomial(2, y=1)])**2 4 2 2 4 x + 4 y + 8 x y |
__repr__(self)
|
__str__(self)
|
__truediv__(self, my_polynomial)Division with __future__.division See also method __div__. |
check_second_term(wrapped)Check if the second term of an operation is a Polynomial |
eval(self, **unknowns)Resolve the polynomial using it as a function P(x, y, ...). Example:>>> p = Polynomial([Monomial(x=2, y=1), Monomial(y=1)]) >>> print p.eval(x=5, y=2) 52Ignore exceeding arguments. |
simplify(self)Simplify the polynomial: sum similar monomials and delete zero-coefficient monomials. In-place method. Example:>>> my_polynomial = Polynomial([Monomial(2, x=2), Monomial(3, x=2), ... Monomial(-4, y=1)]) >>> print my_polynomial.simplify() 2 5 x - 4 y |
| Class Method Details |
|---|
generate(cls, *coefficients)Generate a polynomial instance with given coefficients and specified unknown Example:>>> a = Polynomial.generate(1,2,3) >>> print a 2 x + 2 x + 3 |
| Property Details |
|---|
degreeReturn polynomial's degree. Example:>>> print Polynomial([Monomial(2, x=2), Monomial(-1, y=1)]).degree 2
|
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Fri Aug 10 15:00:04 2007 | http://epydoc.sf.net |