Canola  0.8.D001
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
polyfit Class Reference

#include <polyfit.h>

List of all members.

Public Types

enum  solve_t { solve_ok, solve_singular, solve_insufficient }

Public Member Functions

virtual ~polyfit ()
 polyfit (int order=1)
void enter (double x, double y)
solve_t solve (void)
double coefficient (int n)
double evaluate (double x)
void print (void) const
bool enough_points (void) const

Private Types

typedef long double data_t

Private Member Functions

data_t ** mat_alloc ()
void mat_dump (data_t **data)
void mat_free (data_t **data)
 polyfit ()
 polyfit (const polyfit &)
polyfitoperator= (const polyfit &)

Private Attributes

unsigned int rows
unsigned int cols
data_tcoefficients
data_t ** matrix

Static Private Attributes

static data_t epsilon = 1e-8

Detailed Description

The polyfit class is used to represent the state of a least squares polynomial curve fit.

Definition at line 25 of file polyfit.h.


Member Typedef Documentation

typedef long double polyfit::data_t [private]

Definition at line 113 of file polyfit.h.


Member Enumeration Documentation

Enumerator:
solve_ok 
solve_singular 
solve_insufficient 

Definition at line 52 of file polyfit.h.


Constructor & Destructor Documentation

polyfit::~polyfit ( ) [virtual]

The destructor.

Definition at line 28 of file polyfit.cc.

polyfit::polyfit ( int  order = 1)

The constructor.

Parameters:
orderThe desired order of polynomial; 1 is linear, 2 is quadratic, etc.

Definition at line 37 of file polyfit.cc.

polyfit::polyfit ( ) [private]

The default constructor. Do not use.

polyfit::polyfit ( const polyfit ) [private]

The copy constructor. Do not use.


Member Function Documentation

double polyfit::coefficient ( int  n)

The coefficient method is used to obtain the nth coefficient of the polynomial. Will only produce valid results after the solve method has been called.

Parameters:
nThe number of the coefficient of interest, corresponding to the x**n term.

Definition at line 194 of file polyfit.cc.

bool polyfit::enough_points ( void  ) const [inline]

The enough_points method is used to determine whether or not sufficient points are available for a meaningful solution.

Definition at line 98 of file polyfit.h.

void polyfit::enter ( double  x,
double  y 
)

The enter method is used to add another point to the scatter plot being solved to fit a polynomial.

Parameters:
xThe X coordinate of the point
yThe Y coordinate of the point

Definition at line 49 of file polyfit.cc.

double polyfit::evaluate ( double  x)

The evaluate method is used to evaluate the fitted polynomial, at the given coordinate.

Parameters:
xThe X coordinate of interest.
Returns:
The corresponding Y coordinate.

Definition at line 203 of file polyfit.cc.

polyfit::data_t ** polyfit::mat_alloc ( void  ) [private]

The mat_alloc method is used to allocate a matrix, filled with zero, that is rows rows higth and cols columns wide. This is used to allocate the matrix instance variable, and also the temporary working space used by the solve method.

Definition at line 218 of file polyfit.cc.

void polyfit::mat_dump ( data_t **  data) [private]

The mat_dump method is used to print a prepresentation of the matrix to the standard output. Only usefil for debugging.

Parameters:
dataThe matrix to be printed.

Definition at line 232 of file polyfit.cc.

void polyfit::mat_free ( data_t **  data) [private]

The mat_free method is used to release the memory consumed by a matrix.

Parameters:
dataThe matrix to be released.

Definition at line 245 of file polyfit.cc.

polyfit& polyfit::operator= ( const polyfit ) [private]

The assignment operator. Do not use.

void polyfit::print ( void  ) const

The print method is used to print the polynomial to the standard output. Mostly only useful for debugging.

Definition at line 257 of file polyfit.cc.

The solve method is used to solve the point set to produce a polynomial, once all of the points have been entered using the enter method.

Definition at line 68 of file polyfit.cc.


Member Data Documentation

The coefficients instance variable is used to remember the polynomial coefficients, set bu the solve method.

Definition at line 119 of file polyfit.h.

unsigned int polyfit::cols [private]

The cols instance variable is used to remember the number of columns in the data matrix.

Definition at line 111 of file polyfit.h.

polyfit::data_t polyfit::epsilon = 1e-8 [static, private]

The epsilon class variable is used to remember the value below which a value is considered to be zero.

Definition at line 132 of file polyfit.h.

data_t** polyfit::matrix [private]

The matrix instance variable is used to remember the various summs of paired data, use by the solve method to fit the polynomial to the data.

Definition at line 126 of file polyfit.h.

unsigned int polyfit::rows [private]

The row instance variable is used to remember the number of rows in the data matrix.

Definition at line 105 of file polyfit.h.


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