real polynomial in N variables. More...
#include <vnl_real_npolynomial.h>
Public Member Functions | |
vnl_real_npolynomial () | |
vnl_real_npolynomial (const vnl_vector< double > &c, const vnl_matrix< unsigned int > &p) | |
Construct the polynomial with coefficients vector c and with exponents matrix p. | |
double | eval (const vnl_vector< double > &x) |
Evaluate the polynomial at x. | |
double | deval (const vnl_vector< double > &x, unsigned int i) |
Evaluate the derivative of the polynomial at x with respect to the ith variable. | |
vnl_vector< double > | deval (const vnl_vector< double > &x) |
Evaluate the gradient of the polynomial at x. | |
vnl_real_npolynomial | deriv (unsigned int i) |
Differentiate the polynomial with respect to the ith variable. | |
vnl_real_npolynomial | operator- () const |
vnl_real_npolynomial | operator+ (vnl_real_npolynomial const &) const |
vnl_real_npolynomial | operator- (vnl_real_npolynomial const &) const |
vnl_real_npolynomial | operator* (vnl_real_npolynomial const &) const |
vnl_real_npolynomial & | operator+= (vnl_real_npolynomial const &rhs) |
vnl_real_npolynomial & | operator-= (vnl_real_npolynomial const &rhs) |
vnl_real_npolynomial & | operator*= (vnl_real_npolynomial const &rhs) |
vnl_real_npolynomial | operator+ (double) const |
vnl_real_npolynomial | operator- (double P) const |
vnl_real_npolynomial | operator* (double) const |
vnl_real_npolynomial & | operator*= (double P) |
vnl_real_npolynomial | operator/ (double P) const |
vnl_real_npolynomial & | operator/= (double P) |
unsigned int | degree () const |
Return the degree (highest total power of all terms) of the polynomial. | |
unsigned int | maxdegree () const |
Return the highest degree of the polynomial in an individual variable. | |
vcl_vector< unsigned int > | degrees () const |
Return the degrees (highest power of all terms) in each of the variables. | |
double & | operator[] (unsigned int i) |
Access to the polynomial coefficients. | |
double | operator[] (unsigned int i) const |
Access to the polynomial coefficients. | |
const vnl_vector< double > & | coefficients () const |
Return the vector of coefficients. | |
vnl_vector< double > & | coefficients () |
Return the vector of coefficients. | |
void | set (const vnl_vector< double > &c, const vnl_matrix< unsigned int > &p) |
Set vector of coefficients of each product. | |
const vnl_matrix< unsigned int > & | polyn () const |
Return the polynomial matrix. | |
vnl_matrix< unsigned int > & | polyn () |
Return the vector of coefficients. | |
vcl_string | asString () const |
Return the textual representation of this polynomial. | |
Private Member Functions | |
void | simplify () |
Combine terms with identical exponents (i.e., identical rows in polyn_). | |
double | eval (const vnl_matrix< double > &xn) |
Private Attributes | |
vnl_vector< double > | coeffs_ |
coefficients. | |
vnl_matrix< unsigned int > | polyn_ |
degrees of every term for every variable. | |
unsigned int | nvar_ |
number of variables = # columns of polyn_. | |
unsigned int | nterms_ |
number of terms of polynomial. | |
unsigned int | ideg_ |
max. degree of polynomial. | |
Friends | |
class | vnl_rnpoly_solve |
vcl_ostream & | operator<< (vcl_ostream &, vnl_real_npolynomial const &) |
Related Functions | |
(Note that these are not member functions.) | |
void | vsl_b_write (vsl_b_ostream &os, const vnl_real_npolynomial &v) |
Binary save vnl_real_npolynomial to stream. | |
void | vsl_b_read (vsl_b_istream &is, vnl_real_npolynomial &v) |
Binary load vnl_real_polynomial from stream. | |
void | vsl_print_summary (vcl_ostream &os, const vnl_real_npolynomial &b) |
Print human readable summary of object to a stream. |
real polynomial in N variables.
vnl_real_npolynomial represents a polynomial in multiple variables. Used by vnl_rnpoly_solve which solves systems of polynomial equations. Representation: an N-omial (N terms) is represented by (1) a vector with the N coefficients (vnl_vector<double>), and (2) a matrix with N rows, the i-th row representing the exponents of term i, as follows: (vnl_matrix<int>) column k contains the (integer) exponent of variable k. Example: the polynomial is represented by the coefficients vector [A B C D] and the exponents matrix
[3 0] [1 1] [0 2] [1 2].
Definition at line 54 of file vnl_real_npolynomial.h.
vnl_real_npolynomial::vnl_real_npolynomial | ( | ) | [inline] |
Definition at line 72 of file vnl_real_npolynomial.h.
vnl_real_npolynomial::vnl_real_npolynomial | ( | const vnl_vector< double > & | c, |
const vnl_matrix< unsigned int > & | p | ||
) |
Construct the polynomial with coefficients vector c and with exponents matrix p.
Constructor.
coeffs = vnl_vector<double>(nterms) polyn = vnl_matrix<int>(nterms,nvar) Example: A*x^3 + B*x*y + C*y^2 + D*x*y^2 nvar = 2; nterms = 4; coeffs = [A B C D]'; polyn = [3 0] [1 1] [0 2] [1 2];
Definition at line 31 of file vnl_real_npolynomial.cxx.
vcl_string vnl_real_npolynomial::asString | ( | ) | const |
Return the textual representation of this polynomial.
Definition at line 269 of file vnl_real_npolynomial.cxx.
const vnl_vector<double>& vnl_real_npolynomial::coefficients | ( | ) | const [inline] |
Return the vector of coefficients.
Definition at line 122 of file vnl_real_npolynomial.h.
vnl_vector<double>& vnl_real_npolynomial::coefficients | ( | ) | [inline] |
Return the vector of coefficients.
Definition at line 124 of file vnl_real_npolynomial.h.
unsigned int vnl_real_npolynomial::degree | ( | ) | const |
Return the degree (highest total power of all terms) of the polynomial.
Definition at line 132 of file vnl_real_npolynomial.cxx.
vcl_vector< unsigned int > vnl_real_npolynomial::degrees | ( | ) | const |
Return the degrees (highest power of all terms) in each of the variables.
Definition at line 145 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial vnl_real_npolynomial::deriv | ( | unsigned int | i | ) |
Differentiate the polynomial with respect to the ith variable.
Definition at line 105 of file vnl_real_npolynomial.cxx.
double vnl_real_npolynomial::deval | ( | const vnl_vector< double > & | x, |
unsigned int | i | ||
) |
Evaluate the derivative of the polynomial at x with respect to the ith variable.
Definition at line 90 of file vnl_real_npolynomial.cxx.
vnl_vector< double > vnl_real_npolynomial::deval | ( | const vnl_vector< double > & | x | ) |
Evaluate the gradient of the polynomial at x.
Definition at line 95 of file vnl_real_npolynomial.cxx.
double vnl_real_npolynomial::eval | ( | const vnl_vector< double > & | x | ) |
Evaluate the polynomial at x.
Definition at line 78 of file vnl_real_npolynomial.cxx.
double vnl_real_npolynomial::eval | ( | const vnl_matrix< double > & | xn | ) | [private] |
Definition at line 66 of file vnl_real_npolynomial.cxx.
unsigned int vnl_real_npolynomial::maxdegree | ( | ) | const [inline] |
Return the highest degree of the polynomial in an individual variable.
Definition at line 111 of file vnl_real_npolynomial.h.
vnl_real_npolynomial vnl_real_npolynomial::operator* | ( | vnl_real_npolynomial const & | P | ) | const |
Definition at line 222 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial vnl_real_npolynomial::operator* | ( | double | P | ) | const |
Definition at line 242 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial & vnl_real_npolynomial::operator*= | ( | vnl_real_npolynomial const & | rhs | ) |
Definition at line 265 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial& vnl_real_npolynomial::operator*= | ( | double | P | ) | [inline] |
Definition at line 98 of file vnl_real_npolynomial.h.
vnl_real_npolynomial vnl_real_npolynomial::operator+ | ( | vnl_real_npolynomial const & | P | ) | const |
Definition at line 167 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial vnl_real_npolynomial::operator+ | ( | double | P | ) | const |
Definition at line 186 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial & vnl_real_npolynomial::operator+= | ( | vnl_real_npolynomial const & | rhs | ) |
Definition at line 257 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial vnl_real_npolynomial::operator- | ( | ) | const |
Definition at line 157 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial vnl_real_npolynomial::operator- | ( | vnl_real_npolynomial const & | P | ) | const |
Definition at line 203 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial vnl_real_npolynomial::operator- | ( | double | P | ) | const [inline] |
Definition at line 96 of file vnl_real_npolynomial.h.
vnl_real_npolynomial & vnl_real_npolynomial::operator-= | ( | vnl_real_npolynomial const & | rhs | ) |
Definition at line 261 of file vnl_real_npolynomial.cxx.
vnl_real_npolynomial vnl_real_npolynomial::operator/ | ( | double | P | ) | const [inline] |
Definition at line 99 of file vnl_real_npolynomial.h.
vnl_real_npolynomial& vnl_real_npolynomial::operator/= | ( | double | P | ) | [inline] |
Definition at line 100 of file vnl_real_npolynomial.h.
double& vnl_real_npolynomial::operator[] | ( | unsigned int | i | ) | [inline] |
Access to the polynomial coefficients.
Definition at line 117 of file vnl_real_npolynomial.h.
double vnl_real_npolynomial::operator[] | ( | unsigned int | i | ) | const [inline] |
Access to the polynomial coefficients.
Definition at line 119 of file vnl_real_npolynomial.h.
const vnl_matrix<unsigned int>& vnl_real_npolynomial::polyn | ( | ) | const [inline] |
Return the polynomial matrix.
(ie specifying the variables in each product)
Definition at line 131 of file vnl_real_npolynomial.h.
vnl_matrix<unsigned int>& vnl_real_npolynomial::polyn | ( | ) | [inline] |
Return the vector of coefficients.
Definition at line 134 of file vnl_real_npolynomial.h.
void vnl_real_npolynomial::set | ( | const vnl_vector< double > & | c, |
const vnl_matrix< unsigned int > & | p | ||
) |
Set vector of coefficients of each product.
Definition at line 123 of file vnl_real_npolynomial.cxx.
void vnl_real_npolynomial::simplify | ( | ) | [private] |
Combine terms with identical exponents (i.e., identical rows in polyn_).
Remove terms with zero coefficient, also at the end of the vector.
Definition at line 44 of file vnl_real_npolynomial.cxx.
vcl_ostream& operator<< | ( | vcl_ostream & | os, |
vnl_real_npolynomial const & | P | ||
) | [friend] |
Definition at line 253 of file vnl_real_npolynomial.cxx.
friend class vnl_rnpoly_solve [friend] |
Definition at line 67 of file vnl_real_npolynomial.h.
void vsl_b_read | ( | vsl_b_istream & | is, |
vnl_real_npolynomial & | v | ||
) | [related] |
Binary load vnl_real_polynomial from stream.
Definition at line 28 of file vnl_io_real_npolynomial.cxx.
void vsl_b_write | ( | vsl_b_ostream & | os, |
const vnl_real_npolynomial & | v | ||
) | [related] |
Binary save vnl_real_npolynomial to stream.
Definition at line 17 of file vnl_io_real_npolynomial.cxx.
void vsl_print_summary | ( | vcl_ostream & | os, |
const vnl_real_npolynomial & | b | ||
) | [related] |
Print human readable summary of object to a stream.
Definition at line 54 of file vnl_io_real_npolynomial.cxx.
vnl_vector<double> vnl_real_npolynomial::coeffs_ [private] |
coefficients.
Definition at line 57 of file vnl_real_npolynomial.h.
unsigned int vnl_real_npolynomial::ideg_ [private] |
max. degree of polynomial.
Definition at line 65 of file vnl_real_npolynomial.h.
unsigned int vnl_real_npolynomial::nterms_ [private] |
number of terms of polynomial.
Definition at line 63 of file vnl_real_npolynomial.h.
unsigned int vnl_real_npolynomial::nvar_ [private] |
number of variables = # columns of polyn_.
Definition at line 61 of file vnl_real_npolynomial.h.
vnl_matrix<unsigned int> vnl_real_npolynomial::polyn_ [private] |
degrees of every term for every variable.
Definition at line 59 of file vnl_real_npolynomial.h.