Package controlsystems :: Module types :: Class Polynomial
[hide private]

Class Polynomial

source code

object --+    
         |    
      list --+
             |
            Polynomial

Polynomial type

This class implements the Polynomial type, based on the Python lists. The Polynomial object is a list of coeficients. For example:

>>> a = Polynomial([1, 2, 3])
>>> print a
x^2 + 2x + 3
Instance Methods [hide private]
 
__str__(self)
String representation
source code
 
__add__(self, term)
Operation of addition
source code
 
__sub__(self, term)
Operation of subtraction
source code
 
__mul__(self, term)
Operation of multiplication of polynomials
source code
 
__div__(self, term)
Operation of division of polynomials
source code
 
mult(self, val)
Operation of multiplication between numbers and polynomials
source code
 
Zero(self, order)
Auxiliary method
source code

Inherited from list: __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __iadd__, __imul__, __init__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __reversed__, __rmul__, __setitem__, __setslice__, __sizeof__, append, count, extend, index, insert, pop, remove, reverse, sort

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __subclasshook__

Class Variables [hide private]
  var = 'x'

Inherited from list: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__str__(self)
(Informal representation operator)

source code 
String representation

This method returns the string representation of polynomials.
For example:

    x^2 + 2x + 3

Overrides: object.__str__

__add__(self, term)
(Addition operator)

source code 

Operation of addition

This method returns a Polynomial object with the result of the addition of the Polynomial 'self' and the Polynomial 'term'. For example:

>>> a = Polynomial([1, 2, 3])
>>> b = Polynomial([2, 3, 4])
>>> c = a + b
>>> print c
3x^2 + 5x + 7
>>> type(c)
<class 'controlsystems.types.Polynomial'>
Overrides: list.__add__

__sub__(self, term)
(Subtraction operator)

source code 

Operation of subtraction

This method returns a Polynomial object with the result of the subtraction of the Polynomial 'self' and the Polynomial 'term'. For example:

>>> a = Polynomial([2, 3, 4])
>>> b = Polynomial([1, 2, 3])
>>> c = a - b
>>> print c
x^2 + x + 1
>>> type(c)
<class 'controlsystems.types.Polynomial'>

This method is based on __add__ method

__mul__(self, term)

source code 

Operation of multiplication of polynomials

This method returns a Polynomial object with the result of the multiplication of the Polynomial 'self' and the Polynomial 'term'. For example:

>>> a = Polynomial([1, 2, 3])
>>> b = Polynomial([2, 3, 4])
>>> c = a * b
>>> print c
2x^4 + 7x^3 + 16x^2 + 17x + 12
>>> type(c)
<class 'controlsystems.types.Polynomial'>
Overrides: list.__mul__

__div__(self, term)

source code 

Operation of division of polynomials

This method returns a Polynomial object with the result of the multiplication of the Polynomial 'self' and the Polynomial 'term'.

Not implemented yet.

mult(self, val)

source code 

Operation of multiplication between numbers and polynomials

This method returns a Polynomial object with the result of the multiplication of the Polynomial 'self' and the number 'val'. For example:

>>> a = Polynomial([1, 2, 3])
>>> b = a.mult(5)
>>> print b
5x^2 + 10x + 15
>>> type(b)
<class 'controlsystems.types.Polynomial'>

Zero(self, order)

source code 

Auxiliary method

This method returns a Polynomial object initialized with zeros. For example:

>>> a = Polynomial()
>>> a.Zero(4)
[0, 0, 0, 0]