GetFEM
5.4.2
|
This class deals with plain polynomials with several variables. More...
#include <bgeot_poly.h>
Inherits vector< T >.
Public Member Functions | |
short_type | degree () const |
Gives the degree of the polynomial. | |
short_type | real_degree () const |
gives the degree of the polynomial, considering only non-zero coefficients | |
short_type | dim () const |
Gives the dimension (number of variables) | |
void | change_degree (short_type dd) |
Change the degree of the polynomial to d. | |
void | add_monomial (const T &coeff, const power_index &power) |
Add to the polynomial a monomial of coefficient a and correpsonding to the power index pi. | |
polynomial & | operator+= (const polynomial &Q) |
Add Q to P. P contains the result. | |
polynomial & | operator-= (const polynomial &Q) |
Subtract Q from P. P contains the result. | |
polynomial | operator+ (const polynomial &Q) const |
Add Q to P. | |
polynomial | operator- (const polynomial &Q) const |
Subtract Q from P. | |
polynomial & | operator*= (const polynomial &Q) |
Multiply P with Q. P contains the result. | |
polynomial | operator* (const polynomial &Q) const |
Multiply P with Q. | |
void | direct_product (const polynomial &Q) |
Product of P and Q considering that variables of Q come after variables of P. More... | |
polynomial & | operator*= (const T &e) |
Multiply P with the scalar a. P contains the result. | |
polynomial | operator* (const T &e) const |
Multiply P with the scalar a. | |
polynomial & | operator/= (const T &e) |
Divide P with the scalar a. P contains the result. | |
polynomial | operator/ (const T &e) const |
Divide P with the scalar a. | |
bool | operator== (const polynomial &Q) const |
operator ==. | |
bool | operator!= (const polynomial &Q) const |
operator !=. | |
void | derivative (short_type k) |
Derivative of P with respect to the variable k. P contains the result. | |
void | one () |
Makes P = 1. | |
template<typename ITER > | |
T | eval (const ITER &it) const |
Evaluate the polynomial. More... | |
polynomial () | |
Constructor. | |
polynomial (short_type dim_, short_type degree_) | |
Constructor. | |
polynomial (short_type dim_, short_type degree_, short_type k) | |
Constructor for the polynomial 'x' (k=0), 'y' (k=1), 'z' (k=2) etc. | |
This class deals with plain polynomials with several variables.
A polynomial of variables and degree is stored in a vector of components.
the following code is valid :
The constant coefficient is placed first with the index 0. Two monomials of different degrees are ordered following there respective degree. If two monomials have the same degree, they are ordered with the degree of the mononomials without the n firsts variables which have the same degree. The index of the monomial @f$ x_0^{i_0}x_1^{i_1} ... x_{n-1}^{i_{n-1}} @f$ is then @f$ \alpha_{d-1}^{n} + \alpha_{d-i_0-1}^{n-1} + \alpha_{d-i_0-i_1-1}^{n-2} + ... + \alpha_{i_{n-1}-1}^{1}, @f$ where @f$d = \sum_{l=0}^{n-1} i_l@f$ is the degree of the monomial. (by convention @f$\alpha_{-1}^{n} = 0@f$).
The answer to the question : what is the next and previous monomial of @f$x_0^{i_0}x_1^{i_1} ... x_{n-1}^{i_{n-1}}@f$ in the vector is the following : To take the next coefficient, let @f$l@f$ be the last index between 0 and @f$n-2@f$ such that @f$i_l \ne 0@f$ (@f$l = -1@f$ if there is not), then make the operations @f$a = i_{n-1}; i_{n-1} = 0; i_{l+1} = a+1; \mbox{ if } l \ge 0 \mbox{ then } i_l = i_l - 1@f$. To take the previous coefficient, let @f$l@f$ be the last index between 0 and @f$n-1@f$ such that @f$i_l \ne 0@f$ (if there is not, there is no previous monomial) then make the operations @f$a = i_l; i_l = 0; i_{n-1} = a - 1; \mbox{ if } l \ge 1 \mbox{ then } i_{l-1} = i_{l-1} + 1@f$.
This direct product multiplication of P and Q is the multiplication considering that the variables of Q follow the variables of P. The result is a polynomial with the number of variables of P plus the number of variables of Q. The resulting polynomials have a smaller degree.
Definition at line 180 of file bgeot_poly.h.
void bgeot::polynomial< T >::direct_product | ( | const polynomial< T > & | Q | ) |
Product of P and Q considering that variables of Q come after variables of P.
P contains the result
Definition at line 383 of file bgeot_poly.h.
T bgeot::polynomial< T >::eval | ( | const ITER & | it | ) | const |
Evaluate the polynomial.
"it" is an iterator pointing to the list of variables. A Horner scheme is used.
Definition at line 453 of file bgeot_poly.h.