86. plugins.polynomial — Polynomials¶
This module defines the class Polynomial, representing a polynomial in n variables.
86.1. Classes defined in module plugins.polynomial¶
- 
class plugins.polynomial.Polynomial(exp, coeff=None)[source]¶
- A polynomial in ndim dimensions. - Parameters
- exp (array_like) – An int array of shape (nterms,ndim) with the exponents of each of the ndim variables in each of the nterms terms of the polynomial. 
- coeff (array_like) – A float array with the coefficients of the terms. If not specified, all coefficients are set to 1. 
 
 - Examples - >>> p = Polynomial([(0,0),(1,0),(1,1),(0,2)],(2,3,-1,-1)) >>> print(p.atoms()) ['1', 'x', 'x*y', 'y**2'] >>> print(p.human()) 2.0 + 3.0*x -1.0*x*y -1.0*y**2 >>> print(p.evalAtoms([[1,2],[3,0],[2,1]])) [[1. 1. 2. 4.] [1. 3. 0. 0.] [1. 2. 2. 1.]] >>> print(p.eval([[1,2],[3,0],[2,1]])) [-1. 11. 5.] - 
degrees()[source]¶
- Return the degree of the polynomial in each of the dimensions. - The degree is the maximal exponent for each of the dimensions. 
 - 
degree()[source]¶
- Return the total degree of the polynomial. - The degree is the sum of the degrees for all dimensions. 
 - 
evalAtoms1(x)[source]¶
- Evaluate the monomials at the given points - x is an (npoints,ndim) array of points where the polynomial is to be evaluated. The result is an (npoints,nterms) array of values. 
 - 
evalAtoms(x)[source]¶
- Evaluate the monomials at the given points - x is an (npoints,ndim) array of points where the polynomial is to be evaluated. The result is an (npoints,nterms) array of values. 
 
86.2. Functions defined in module plugins.polynomial¶
- 
plugins.polynomial.polynomial(atoms, x, y=0, z=0)[source]¶
- Build a matrix of functions of coords. - atoms: a list of text strings representing a mathematical function of x, and possibly of y and z. 
- x, y, z: a list of x- (and optionally y-, z-) values at which the atoms will be evaluated. The lists should have the same length. 
 - Returns a matrix with nvalues rows and natoms colums. 
- 
plugins.polynomial.monomial(exp, symbol='xyz')[source]¶
- Compute the monomials for the given exponents - exp: a tuple of integer exponents 
- symbol: a string of at least the same length as exp 
 - Returns a string representation of a monomial created by raising the symbols to the corresponding exponent. - Example: - >>> monomial((2,1)) 'x**2*y' 
 
  