NZMATH  1.2.0
About: NZMATH is a Python based number theory oriented calculation system.
  Fossies Dox: NZMATH-1.2.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

nzmath.poly.univar.SortedPolynomial Class Reference
Inheritance diagram for nzmath.poly.univar.SortedPolynomial:
[legend]
Collaboration diagram for nzmath.poly.univar.SortedPolynomial:
[legend]

Public Member Functions

def __init__ (self, coefficients, _sorted=False, **kwds)
 
def __pos__ (self)
 
def __neg__ (self)
 
def __add__ (self, other)
 
def __sub__ (self, other)
 
def __mul__ (self, other)
 
def __rmul__ (self, other)
 
def ring_mul_karatsuba (self, other)
 
def scalar_mul (self, scale)
 
def square (self)
 
def __pow__ (self, index)
 
def degree (self)
 
def leading_coefficient (self)
 
def leading_term (self)
 
def iterterms (self)
 
def iterbases (self)
 
def itercoefficients (self)
 
def __getitem__ (self, degree)
 
def __contains__ (self, degree)
 
def __len__ (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __call__ (self, val)
 
def __repr__ (self)
 
- Public Member Functions inherited from nzmath.poly.univar.PolynomialInterface
def __init__ (self, coefficients, **kwds)
 
def ring_mul (self, other)
 
def term_mul (self, term)
 
def differentiate (self)
 
def upshift_degree (self, slide)
 
def downshift_degree (self, slide)
 
def terms_map (self, func)
 
def construct_with_default (self, terms)
 
- Public Member Functions inherited from nzmath.poly.formalsum.FormalSumContainerInterface
def __iter__ (self)
 
def __ne__ (self, other)
 
def __nonzero__ (self)
 
def terms (self)
 
def coefficients (self)
 
def bases (self)
 
def coefficients_map (self, func)
 
def bases_map (self, func)
 

Public Attributes

 sorted
 
- Public Attributes inherited from nzmath.poly.univar.PolynomialInterface
 number_of_variables
 

Private Member Functions

def _insort (self, term)
 
def _bisect (self, degree)
 

Private Attributes

 _init_kwds
 

Detailed Description

SortedPolynomial stores terms of a polynomial in sorted manner.
All methods and operations keep it sorted.

Definition at line 360 of file univar.py.

Constructor & Destructor Documentation

◆ __init__()

def nzmath.poly.univar.SortedPolynomial.__init__ (   self,
  coefficients,
  _sorted = False,
**  kwds 
)
SortedPolynomial(coefficients)

'coefficients' can be any dict initial values.
Optionally '_sorted' can be True if the coefficients is
already sorted.

Definition at line 365 of file univar.py.

Member Function Documentation

◆ __add__()

def nzmath.poly.univar.SortedPolynomial.__add__ (   self,
  other 
)

◆ __call__()

def nzmath.poly.univar.SortedPolynomial.__call__ (   self,
  val 
)
substitution

Definition at line 805 of file univar.py.

References nzmath.poly.univar.SortedPolynomial.sorted.

◆ __contains__()

def nzmath.poly.univar.SortedPolynomial.__contains__ (   self,
  degree 
)
Return True if there is a term of specified degree.
False otherwise.

Reimplemented from nzmath.poly.formalsum.FormalSumContainerInterface.

Definition at line 773 of file univar.py.

References nzmath.poly.univar.SortedPolynomial._bisect(), and nzmath.poly.univar.SortedPolynomial.sorted.

◆ __eq__()

def nzmath.poly.univar.SortedPolynomial.__eq__ (   self,
  other 
)

◆ __getitem__()

def nzmath.poly.univar.SortedPolynomial.__getitem__ (   self,
  degree 
)
Return the coefficient of specified degree.
If there is no term of degree, return 0.

Reimplemented from nzmath.poly.formalsum.FormalSumContainerInterface.

Reimplemented in nzmath.poly.uniutil.RingPolynomial.

Definition at line 762 of file univar.py.

References nzmath.poly.univar.SortedPolynomial._bisect(), and nzmath.poly.univar.SortedPolynomial.sorted.

◆ __hash__()

def nzmath.poly.univar.SortedPolynomial.__hash__ (   self)

Reimplemented from nzmath.poly.univar.PolynomialInterface.

Definition at line 801 of file univar.py.

◆ __len__()

def nzmath.poly.univar.SortedPolynomial.__len__ (   self)
Return the number of data entries.

Reimplemented from nzmath.poly.formalsum.FormalSumContainerInterface.

Definition at line 783 of file univar.py.

References nzmath.poly.univar.SortedPolynomial.sorted.

◆ __mul__()

◆ __neg__()

def nzmath.poly.univar.SortedPolynomial.__neg__ (   self)

◆ __pos__()

def nzmath.poly.univar.SortedPolynomial.__pos__ (   self)

◆ __pow__()

◆ __repr__()

def nzmath.poly.univar.SortedPolynomial.__repr__ (   self)

Reimplemented in nzmath.poly.uniutil.RingPolynomial.

Definition at line 824 of file univar.py.

References nzmath.poly.univar.SortedPolynomial.sorted.

◆ __rmul__()

def nzmath.poly.univar.SortedPolynomial.__rmul__ (   self,
  other 
)
other * self

If type of other does not support multiplication with self
from left, this method is called.  In the context, it is only
posiible that other be a scalar.

Reimplemented from nzmath.poly.formalsum.FormalSumContainerInterface.

Definition at line 548 of file univar.py.

References nzmath.poly.univar.PolynomialInterface.scalar_mul(), nzmath.poly.array.ArrayPoly.scalar_mul(), nzmath.poly.multivar.BasicPolynomial.scalar_mul(), nzmath.poly.array.ArrayPolyMod.scalar_mul(), nzmath.poly.formalsum.DictFormalSum.scalar_mul(), and nzmath.poly.formalsum.ListFormalSum.scalar_mul().

◆ __sub__()

def nzmath.poly.univar.SortedPolynomial.__sub__ (   self,
  other 
)

◆ _bisect()

def nzmath.poly.univar.SortedPolynomial._bisect (   self,
  degree 
)
private
Return the index where to insert term of degree.

- This method is not in a part of the API.
- The code is just adapting bisect.bisect_right to the
  context.

Definition at line 392 of file univar.py.

References nzmath.poly.univar.SortedPolynomial.sorted.

Referenced by nzmath.poly.univar.SortedPolynomial.__contains__(), nzmath.poly.univar.SortedPolynomial.__getitem__(), nzmath.poly.univar.SortedPolynomial._insort(), nzmath.poly.univar.SortedPolynomial.ring_mul_karatsuba(), and nzmath.poly.univar.SortedPolynomial.square().

◆ _insort()

def nzmath.poly.univar.SortedPolynomial._insort (   self,
  term 
)
private
Insert the term into self.seorted list, and keep it sorted.

- This method is destructive.
- This method is not in a part of the API.

Definition at line 383 of file univar.py.

References nzmath.poly.univar.SortedPolynomial._bisect(), and nzmath.poly.univar.SortedPolynomial.sorted.

◆ degree()

def nzmath.poly.univar.SortedPolynomial.degree (   self)

◆ iterbases()

def nzmath.poly.univar.SortedPolynomial.iterbases (   self)
iterator for bases.

Reimplemented from nzmath.poly.formalsum.FormalSumContainerInterface.

Definition at line 748 of file univar.py.

References nzmath.poly.univar.SortedPolynomial.sorted.

◆ itercoefficients()

◆ iterterms()

def nzmath.poly.univar.SortedPolynomial.iterterms (   self)
iterator for (base, coefficient) pairs.
The iterator is equivalent to
  zip(self.iterbases(), self.itercoefficients())

Reimplemented from nzmath.poly.formalsum.FormalSumContainerInterface.

Definition at line 740 of file univar.py.

References nzmath.poly.univar.SortedPolynomial.sorted.

◆ leading_coefficient()

def nzmath.poly.univar.SortedPolynomial.leading_coefficient (   self)

◆ leading_term()

def nzmath.poly.univar.SortedPolynomial.leading_term (   self)
Return the leading term as a tuple (degree, coefficient).

Definition at line 730 of file univar.py.

References nzmath.poly.univar.SortedPolynomial.sorted.

◆ ring_mul_karatsuba()

◆ scalar_mul()

◆ square()

Member Data Documentation

◆ _init_kwds

◆ sorted


The documentation for this class was generated from the following file: