Public Member Functions | Private Member Functions | Private Attributes | Friends | Related Functions | List of all members
vnl_real_npolynomial Class Reference

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. More...
 
double eval (const vnl_vector< double > &x)
 Evaluate the polynomial at x. More...
 
double deval (const vnl_vector< double > &x, unsigned int i)
 Evaluate the derivative of the polynomial at x with respect to the ith variable. More...
 
vnl_vector< double > deval (const vnl_vector< double > &x)
 Evaluate the gradient of the polynomial at x. More...
 
vnl_real_npolynomial deriv (unsigned int i)
 Differentiate the polynomial with respect to the ith variable. More...
 
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_npolynomialoperator+= (vnl_real_npolynomial const &rhs)
 
vnl_real_npolynomialoperator-= (vnl_real_npolynomial const &rhs)
 
vnl_real_npolynomialoperator *= (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_npolynomialoperator *= (double P)
 
vnl_real_npolynomial operator/ (double P) const
 
vnl_real_npolynomialoperator/= (double P)
 
unsigned int degree () const
 Return the degree (highest total power of all terms) of the polynomial. More...
 
unsigned int maxdegree () const
 Return the highest degree of the polynomial in an individual variable. More...
 
std::vector< unsigned int > degrees () const
 Return the degrees (highest power of all terms) in each of the variables. More...
 
double & operator [] (unsigned int i)
 Access to the polynomial coefficients. More...
 
double operator [] (unsigned int i) const
 Access to the polynomial coefficients. More...
 
const vnl_vector< double > & coefficients () const
 Return the vector of coefficients. More...
 
vnl_vector< double > & coefficients ()
 Return the vector of coefficients. More...
 
void set (const vnl_vector< double > &c, const vnl_matrix< unsigned int > &p)
 Set vector of coefficients of each product. More...
 
const vnl_matrix< unsigned int > & polyn () const
 Return the polynomial matrix. More...
 
vnl_matrix< unsigned int > & polyn ()
 Return the vector of coefficients. More...
 
std::string asString () const
 Return the textual representation of this polynomial. More...
 

Private Member Functions

void simplify ()
 Combine terms with identical exponents (i.e., identical rows in polyn_). More...
 
double eval (const vnl_matrix< double > &xn)
 

Private Attributes

vnl_vector< double > coeffs_
 coefficients. More...
 
vnl_matrix< unsigned int > polyn_
 degrees of every term for every variable. More...
 
unsigned int nvar_
 number of variables = # columns of polyn_. More...
 
unsigned int nterms_
 number of terms of polynomial. More...
 
unsigned int ideg_
 max. degree of polynomial. More...
 

Friends

class vnl_rnpoly_solve
 
VNL_EXPORT std::ostream & operator<< (std::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. More...
 
void vsl_b_read (vsl_b_istream &is, vnl_real_npolynomial &v)
 Binary load vnl_real_polynomial from stream. More...
 
void vsl_print_summary (std::ostream &os, const vnl_real_npolynomial &b)
 Print human readable summary of object to a stream. More...
 

Detailed Description

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 $A X^3 + B XY + C Y^2 + D XY^2$ 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 55 of file vnl_real_npolynomial.h.

Constructor & Destructor Documentation

◆ vnl_real_npolynomial() [1/2]

vnl_real_npolynomial::vnl_real_npolynomial ( )
inline

Definition at line 74 of file vnl_real_npolynomial.h.

◆ vnl_real_npolynomial() [2/2]

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 28 of file vnl_real_npolynomial.cxx.

Member Function Documentation

◆ asString()

std::string vnl_real_npolynomial::asString ( ) const

Return the textual representation of this polynomial.

Definition at line 266 of file vnl_real_npolynomial.cxx.

◆ coefficients() [1/2]

const vnl_vector<double>& vnl_real_npolynomial::coefficients ( ) const
inline

Return the vector of coefficients.

Definition at line 124 of file vnl_real_npolynomial.h.

◆ coefficients() [2/2]

vnl_vector<double>& vnl_real_npolynomial::coefficients ( )
inline

Return the vector of coefficients.

Definition at line 126 of file vnl_real_npolynomial.h.

◆ degree()

unsigned int vnl_real_npolynomial::degree ( ) const

Return the degree (highest total power of all terms) of the polynomial.

Definition at line 129 of file vnl_real_npolynomial.cxx.

◆ degrees()

std::vector< unsigned int > vnl_real_npolynomial::degrees ( ) const

Return the degrees (highest power of all terms) in each of the variables.

Definition at line 142 of file vnl_real_npolynomial.cxx.

◆ deriv()

vnl_real_npolynomial vnl_real_npolynomial::deriv ( unsigned int  i)

Differentiate the polynomial with respect to the ith variable.

Definition at line 102 of file vnl_real_npolynomial.cxx.

◆ deval() [1/2]

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 87 of file vnl_real_npolynomial.cxx.

◆ deval() [2/2]

vnl_vector< double > vnl_real_npolynomial::deval ( const vnl_vector< double > &  x)

Evaluate the gradient of the polynomial at x.

Definition at line 92 of file vnl_real_npolynomial.cxx.

◆ eval() [1/2]

double vnl_real_npolynomial::eval ( const vnl_vector< double > &  x)

Evaluate the polynomial at x.

Definition at line 75 of file vnl_real_npolynomial.cxx.

◆ eval() [2/2]

double vnl_real_npolynomial::eval ( const vnl_matrix< double > &  xn)
private

Definition at line 63 of file vnl_real_npolynomial.cxx.

◆ maxdegree()

unsigned int vnl_real_npolynomial::maxdegree ( ) const
inline

Return the highest degree of the polynomial in an individual variable.

Definition at line 113 of file vnl_real_npolynomial.h.

◆ operator *() [1/2]

vnl_real_npolynomial vnl_real_npolynomial::operator * ( vnl_real_npolynomial const &  P) const

Definition at line 219 of file vnl_real_npolynomial.cxx.

◆ operator *() [2/2]

vnl_real_npolynomial vnl_real_npolynomial::operator * ( double  P) const

Definition at line 239 of file vnl_real_npolynomial.cxx.

◆ operator *=() [1/2]

vnl_real_npolynomial & vnl_real_npolynomial::operator *= ( vnl_real_npolynomial const &  rhs)

Definition at line 262 of file vnl_real_npolynomial.cxx.

◆ operator *=() [2/2]

vnl_real_npolynomial& vnl_real_npolynomial::operator *= ( double  P)
inline

Definition at line 100 of file vnl_real_npolynomial.h.

◆ operator []() [1/2]

double& vnl_real_npolynomial::operator [] ( unsigned int  i)
inline

Access to the polynomial coefficients.

Definition at line 119 of file vnl_real_npolynomial.h.

◆ operator []() [2/2]

double vnl_real_npolynomial::operator [] ( unsigned int  i) const
inline

Access to the polynomial coefficients.

Definition at line 121 of file vnl_real_npolynomial.h.

◆ operator+() [1/2]

vnl_real_npolynomial vnl_real_npolynomial::operator+ ( vnl_real_npolynomial const &  P) const

Definition at line 164 of file vnl_real_npolynomial.cxx.

◆ operator+() [2/2]

vnl_real_npolynomial vnl_real_npolynomial::operator+ ( double  P) const

Definition at line 183 of file vnl_real_npolynomial.cxx.

◆ operator+=()

vnl_real_npolynomial & vnl_real_npolynomial::operator+= ( vnl_real_npolynomial const &  rhs)

Definition at line 254 of file vnl_real_npolynomial.cxx.

◆ operator-() [1/3]

vnl_real_npolynomial vnl_real_npolynomial::operator- ( ) const

Definition at line 154 of file vnl_real_npolynomial.cxx.

◆ operator-() [2/3]

vnl_real_npolynomial vnl_real_npolynomial::operator- ( vnl_real_npolynomial const &  P) const

Definition at line 200 of file vnl_real_npolynomial.cxx.

◆ operator-() [3/3]

vnl_real_npolynomial vnl_real_npolynomial::operator- ( double  P) const
inline

Definition at line 98 of file vnl_real_npolynomial.h.

◆ operator-=()

vnl_real_npolynomial & vnl_real_npolynomial::operator-= ( vnl_real_npolynomial const &  rhs)

Definition at line 258 of file vnl_real_npolynomial.cxx.

◆ operator/()

vnl_real_npolynomial vnl_real_npolynomial::operator/ ( double  P) const
inline

Definition at line 101 of file vnl_real_npolynomial.h.

◆ operator/=()

vnl_real_npolynomial& vnl_real_npolynomial::operator/= ( double  P)
inline

Definition at line 102 of file vnl_real_npolynomial.h.

◆ polyn() [1/2]

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 133 of file vnl_real_npolynomial.h.

◆ polyn() [2/2]

vnl_matrix<unsigned int>& vnl_real_npolynomial::polyn ( )
inline

Return the vector of coefficients.

Definition at line 136 of file vnl_real_npolynomial.h.

◆ set()

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 120 of file vnl_real_npolynomial.cxx.

◆ simplify()

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 41 of file vnl_real_npolynomial.cxx.

Friends And Related Function Documentation

◆ operator<<

VNL_EXPORT std::ostream& operator<< ( std::ostream &  ,
vnl_real_npolynomial const &   
)
friend

Definition at line 250 of file vnl_real_npolynomial.cxx.

◆ vnl_rnpoly_solve

friend class vnl_rnpoly_solve
friend

Definition at line 69 of file vnl_real_npolynomial.h.

◆ vsl_b_read()

void vsl_b_read ( vsl_b_istream &  is,
vnl_real_npolynomial v 
)
related

Binary load vnl_real_polynomial from stream.

Definition at line 23 of file vnl_io_real_npolynomial.cxx.

◆ vsl_b_write()

void vsl_b_write ( vsl_b_ostream &  os,
const vnl_real_npolynomial v 
)
related

Binary save vnl_real_npolynomial to stream.

Definition at line 12 of file vnl_io_real_npolynomial.cxx.

◆ vsl_print_summary()

void vsl_print_summary ( std::ostream &  os,
const vnl_real_npolynomial b 
)
related

Print human readable summary of object to a stream.

Definition at line 49 of file vnl_io_real_npolynomial.cxx.

Member Data Documentation

◆ coeffs_

vnl_vector<double> vnl_real_npolynomial::coeffs_
private

coefficients.

Definition at line 59 of file vnl_real_npolynomial.h.

◆ ideg_

unsigned int vnl_real_npolynomial::ideg_
private

max. degree of polynomial.

Definition at line 67 of file vnl_real_npolynomial.h.

◆ nterms_

unsigned int vnl_real_npolynomial::nterms_
private

number of terms of polynomial.

Definition at line 65 of file vnl_real_npolynomial.h.

◆ nvar_

unsigned int vnl_real_npolynomial::nvar_
private

number of variables = # columns of polyn_.

Definition at line 63 of file vnl_real_npolynomial.h.

◆ polyn_

vnl_matrix<unsigned int> vnl_real_npolynomial::polyn_
private

degrees of every term for every variable.

Definition at line 61 of file vnl_real_npolynomial.h.


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