Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vnl_real_polynomial Class Reference

#include <vnl_real_polynomial.h>

List of all members.


Detailed Description

Evaluation of real polynomials at real and complex points.

vnl_real_polynomial represents a univariate polynomial with real coefficients, stored as a vector of doubles. This allows evaluation of the polynomial $p(x)$ at given values of $x$ , or of its derivative $p'(x)$ .

Roots may be extracted using the roots() method.

Definition at line 34 of file vnl_real_polynomial.h.

Public Member Functions

 vnl_real_polynomial (vnl_vector< double > const &a)
 Initialize polynomial.
 vnl_real_polynomial (double const *a, unsigned len)
 Initialize polynomial from C vector.
 vnl_real_polynomial (double a)
 Initialize polynomial from double.
 vnl_real_polynomial (int d)
 Initialize polynomial of a given degree.
bool operator== (vnl_real_polynomial const &p) const
 comparison operator.
double evaluate (double x) const
 Evaluate polynomial at value x.
double evaluate_integral (double x) const
 Evaluate integral at x (assuming constant of integration is zero).
double evaluate_integral (double x1, double x2) const
 Evaluate integral between x1 and x2.
double devaluate (double x) const
 Evaluate derivative at value x.
vcl_complex< double > evaluate (vcl_complex< double > const &x) const
 Evaluate polynomial at complex value x.
vcl_complex< double > devaluate (vcl_complex< double > const &x) const
 Evaluate derivative at complex value x.
vnl_real_polynomial derivative () const
 Return derivative of this polynomial.
vnl_real_polynomial primitive () const
 Return primitive function (inverse derivative) of this polynomial.
int degree () const
 Return the degree (highest power of x) of the polynomial.
double & operator[] (int i)
 Access to the polynomial coefficients.
double operator[] (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_coefficients (vnl_vector< double > const &coeffs)
void print (vcl_ostream &os) const
 Print this polynomial to stream.

Protected Attributes

vnl_vector< double > coeffs_
 The coefficients of the polynomial.

Related Functions

(Note that these are not member functions.)

vnl_real_polynomial operator+ (const vnl_real_polynomial &f1, const vnl_real_polynomial &f2)
 Returns polynomial which is sum of two polynomials f1(x)+f2(x).
vnl_real_polynomial operator- (const vnl_real_polynomial &f1, const vnl_real_polynomial &f2)
 Returns polynomial which is different of two polynomials f1(x)-f2(x).
double vnl_rms_difference (const vnl_real_polynomial &f1, const vnl_real_polynomial &f2, double x1, double x2)
 Returns RMS difference between f1 and f2 over range [x1,x2].


Constructor & Destructor Documentation

vnl_real_polynomial::vnl_real_polynomial vnl_vector< double > const &  a  )  [inline]
 

Initialize polynomial.

The polynomial is $ a[0] x^d + a[1] x^{d-1} + \cdots + a[d] = 0 $ .

Definition at line 39 of file vnl_real_polynomial.h.

vnl_real_polynomial::vnl_real_polynomial double const *  a,
unsigned  len
[inline]
 

Initialize polynomial from C vector.

The parameter len is the number of coefficients, one greater than the degree.

Definition at line 46 of file vnl_real_polynomial.h.

vnl_real_polynomial::vnl_real_polynomial double  a  )  [inline]
 

Initialize polynomial from double.

Useful when adding or multiplying a polynomial and a number.

Definition at line 52 of file vnl_real_polynomial.h.

vnl_real_polynomial::vnl_real_polynomial int  d  )  [inline]
 

Initialize polynomial of a given degree.

Definition at line 55 of file vnl_real_polynomial.h.


Member Function Documentation

vnl_vector<double>& vnl_real_polynomial::coefficients  )  [inline]
 

Return the vector of coefficients.

Definition at line 99 of file vnl_real_polynomial.h.

const vnl_vector<double>& vnl_real_polynomial::coefficients  )  const [inline]
 

Return the vector of coefficients.

Definition at line 97 of file vnl_real_polynomial.h.

int vnl_real_polynomial::degree  )  const [inline]
 

Return the degree (highest power of x) of the polynomial.

Definition at line 89 of file vnl_real_polynomial.h.

vnl_real_polynomial vnl_real_polynomial::derivative  )  const
 

Return derivative of this polynomial.

Definition at line 176 of file vnl_real_polynomial.cxx.

vcl_complex< double > vnl_real_polynomial::devaluate vcl_complex< double > const &  x  )  const
 

Evaluate derivative at complex value x.

Definition at line 71 of file vnl_real_polynomial.cxx.

double vnl_real_polynomial::devaluate double  x  )  const
 

Evaluate derivative at value x.

Definition at line 64 of file vnl_real_polynomial.cxx.

vcl_complex<double> vnl_real_polynomial::evaluate vcl_complex< double > const &  x  )  const
 

Evaluate polynomial at complex value x.

double vnl_real_polynomial::evaluate double  x  )  const
 

Evaluate polynomial at value x.

double vnl_real_polynomial::evaluate_integral double  x1,
double  x2
const
 

Evaluate integral between x1 and x2.

Definition at line 95 of file vnl_real_polynomial.cxx.

double vnl_real_polynomial::evaluate_integral double  x  )  const
 

Evaluate integral at x (assuming constant of integration is zero).

Definition at line 77 of file vnl_real_polynomial.cxx.

bool vnl_real_polynomial::operator== vnl_real_polynomial const &  p  )  const [inline]
 

comparison operator.

Definition at line 58 of file vnl_real_polynomial.h.

double vnl_real_polynomial::operator[] int  i  )  const [inline]
 

Access to the polynomial coefficients.

Definition at line 94 of file vnl_real_polynomial.h.

double& vnl_real_polynomial::operator[] int  i  )  [inline]
 

Access to the polynomial coefficients.

Definition at line 92 of file vnl_real_polynomial.h.

vnl_real_polynomial vnl_real_polynomial::primitive  )  const
 

Return primitive function (inverse derivative) of this polynomial.

Since a primitive function is not unique, the one with constant = 0 is returned

Definition at line 188 of file vnl_real_polynomial.cxx.

void vnl_real_polynomial::print vcl_ostream &  os  )  const
 

Print this polynomial to stream.

Definition at line 199 of file vnl_real_polynomial.cxx.

void vnl_real_polynomial::set_coefficients vnl_vector< double > const &  coeffs  )  [inline]
 

Definition at line 101 of file vnl_real_polynomial.h.


Friends And Related Function Documentation

vnl_real_polynomial operator+ const vnl_real_polynomial f1,
const vnl_real_polynomial f2
[related]
 

Returns polynomial which is sum of two polynomials f1(x)+f2(x).

Definition at line 101 of file vnl_real_polynomial.cxx.

vnl_real_polynomial operator- const vnl_real_polynomial f1,
const vnl_real_polynomial f2
[related]
 

Returns polynomial which is different of two polynomials f1(x)-f2(x).

Definition at line 123 of file vnl_real_polynomial.cxx.

double vnl_rms_difference const vnl_real_polynomial f1,
const vnl_real_polynomial f2,
double  x1,
double  x2
[related]
 

Returns RMS difference between f1 and f2 over range [x1,x2].

$\frac1{\sqrt{|x_2-x_1|}}\,\sqrt{\int_{x_1}^{x_2}\left(f_1(x)-f_2(x)\right)^2\,dx}$

Definition at line 163 of file vnl_real_polynomial.cxx.


Member Data Documentation

vnl_vector<double> vnl_real_polynomial::coeffs_ [protected]
 

The coefficients of the polynomial.

coeffs_.back() is the const term. coeffs_[n] is the coefficient of the x^(d-n) term, where d=coeffs_.size()-1

Invariant:
coeffs_size() >= 1;

Definition at line 112 of file vnl_real_polynomial.h.


The documentation for this class was generated from the following files:
Generated on Thu Jan 10 14:37:40 2008 for core/vnl by  doxygen 1.4.4