The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fib::algorithms::nD1::cPolynom< tX, tY > Class Template Reference

#include <cPolynom.h>

Inheritance diagram for fib::algorithms::nD1::cPolynom< tX, tY >:
Collaboration diagram for fib::algorithms::nD1::cPolynom< tX, tY >:

List of all members.

Public Member Functions

 cPolynom ()
virtual tY evalue (const tX &x) const
virtual void print (ostream &outputStream) const
virtual pair< unsigned long, tY > evalueError (const vector< cDataPoint< tX, tY > > &vecInput) const
virtual tY evalueErrorMax (const vector< cDataPoint< tX, tY > > &vecData, const tY maxYError) const
virtual pair< unsigned long, tY > evalueError (const vector< cDataPointRange< tX, tY > > &vecInput) const
virtual tY evalueErrorMax (const vector< cDataPointRange< tX, tY > > &vecData, const tY maxYError) const
virtual vector
< cLinearEquation< tY > > 
createLinearEquations (const vector< cDataPoint< tX, tY > > &vecData, unsigned int uiMaxPolynomOrder) const
pair< cInequation< tY >
, cInequation< tY > > 
createInequiationsForRangePoint (const cDataPointRange< tX, tY > &dataPoint, unsigned int uiPolynomOrder) const
long getLastFactorIndexNotNull () const
virtual cUnderFunctiontoFibUnderFunction (cFibVariable *pVariable) const
virtual bool evalue (const vector< cDataPoint< tX, tY > > &vecInputData)
virtual tY findFunctionRand (const vector< cDataPointRange< tX, tY > > &vecInputData, unsigned long ulMaxIterations=256 *256 *256)
virtual tY evalueGoodPolynom (const vector< cDataPointRange< tX, tY > > &vecInputData, unsigned long ulTimeNeed=1024)
virtual unsigned long evalueSpline (const vector< cDataPointRange< tX, tY > > &vecInputData, unsigned int uiNumberOfParameters=4, const unsigned int uiMinBitsToStoreMantissa=1, const tY maxValue=1E+36, const unsigned long ulMaxMemoryCost=0)
virtual unsigned long evalueSplineIterativFast (const vector< cDataPointRange< tX, tY > > &vecInputData, unsigned int uiMaxNumberOfParameters=4, const unsigned int uiMinBitsToStoreMantissa=1, const tY maxValue=1E+36, const tY maxError=0, const unsigned long ulMaxMemoryCost=0)
virtual bool operator== (const cPolynom< tX, tY > &polynom) const
virtual bool operator!= (const cPolynom< tX, tY > &polynom) const

Public Attributes

vector< tY > vecFactors

Detailed Description

template<class tX, class tY>
class fib::algorithms::nD1::cPolynom< tX, tY >

Definition at line 70 of file cPolynom.h.


Constructor & Destructor Documentation

template<class tX, class tY>
fib::algorithms::nD1::cPolynom< tX, tY >::cPolynom ( )

Standartconstructor


Member Function Documentation

template<class tX, class tY>
pair< cInequation< tY >, cInequation< tY > > fib::algorithms::nD1::cPolynom< tX, tY >::createInequiationsForRangePoint ( const cDataPointRange< tX, tY > &  dataPoint,
unsigned int  uiPolynomOrder 
) const

This function creats the two inequiations for the range data point. This inequiations restrict the values in the same way as the range data point and have the form: minY <= a_0 + a_1 * x + a_2 * x^2 + ... ... + a_{uiPolynomOrder-1} * x^(uiPolynomOrder-1) and -1 * maxY <= -1 * a_0 - a_1 * x - a_2 * x^2 - ... ... - a_{uiPolynomOrder-1} * x^(uiPolynomOrder-1)

Parameters:
dataPointthe range datapoint, for which to create the inequiations
uiPolynomOrderthe order for the polynom, which builds the inequiations
Returns:
the two polynom inequiations as a pair, which restrict the values in the same way as the range datapoint
template<class tX, class tY>
virtual vector< cLinearEquation<tY> > fib::algorithms::nD1::cPolynom< tX, tY >::createLinearEquations ( const vector< cDataPoint< tX, tY > > &  vecData,
unsigned int  uiMaxPolynomOrder 
) const
virtual

This function creats the linear equiations (

See also:
cLinearEquation ) for the given datapoints. The linear equiations will have the form: vecData.y = x_0 + vecData.x * x_1 + vecData.x^2 * x_2 + ... + vecData.x^(uiMaxPolynomOrder - 1) * x_{uiMaxPolynomOrder - 1}
Parameters:
vecDatathe with the datapoints, for which to evalue the linear equiations
uiMaxPolynomOrderthe maximal order of the polynom to generate the factor ranges for
Returns:
a vector with the linear equiations for the datapoints
template<class tX, class tY>
virtual tY fib::algorithms::nD1::cPolynom< tX, tY >::evalue ( const tX &  x) const
virtual

This method evalues the value of this polynom.

The evalued function is: f( x ) = vecFactors[ 0 ] + vecFactors[ 1 ] * x + vecFactors[ 2 ] * x^2 + ... + vecFactors[ vecFactors.size() - 1 ] * x^(vecFactors.size() - 1)

Parameters:
xthe input value for the polynom
Returns:
the evalued value f( x )

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.

template<class tX, class tY>
virtual bool fib::algorithms::nD1::cPolynom< tX, tY >::evalue ( const vector< cDataPoint< tX, tY > > &  vecInputData)
virtual

This function evalues the polynom for the given data. The evalued polynom will have the order n of the number of given datapoints.

Parameters:
vecInputDatathe data for which to evalue the polynom
Returns:
if an polynom for the datapoints could be evalued, the factors of the evalued polynom in this polynom and true, else false

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.

template<class tX, class tY>
virtual pair<unsigned long, tY> fib::algorithms::nD1::cPolynom< tX, tY >::evalueError ( const vector< cDataPoint< tX, tY > > &  vecInput) const
virtual

This method evalues the error of the given datapoints to the values this polynom evalues to.

The evaluation of the polynom will be done by evalue(). The error will just be counted, if it is greater than the SAVE_BOUNDERY.

See also:
evalue()
Parameters:
vecInputthe data for wich the error is to evalue
Returns:
a pair with two values:
  • the first value is the number of datapoints evalued wrong
  • the second value is the sum of the error of all datapoints

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.

template<class tX, class tY>
virtual pair<unsigned long, tY> fib::algorithms::nD1::cPolynom< tX, tY >::evalueError ( const vector< cDataPointRange< tX, tY > > &  vecInput) const
virtual

This method evalues the error of the given range datapoints to the values this polynom evalues to.

The evaluation of the polynom will be done by evalue(). A datapoint has an error, if it lay outside the datpoint range. The error is it's distance to the neares datapoint boundery. The error will just be counted, if it is greater than the SAVE_BOUNDERY.

See also:
evalue()
Parameters:
vecInputthe data for wich the error is to evalue
Returns:
a pair with two values:
  • the first value is the number of datapoints evalued wrong
  • the second value is the sum of the error of all datapoints

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.

template<class tX, class tY>
virtual tY fib::algorithms::nD1::cPolynom< tX, tY >::evalueErrorMax ( const vector< cDataPoint< tX, tY > > &  vecData,
const tY  maxYError 
) const
virtual

This method evalues the error of the given datapoints to the values this polynom evalues to. This function will stop the evaluation, if the maximum error maxYError was reached.

The evaluation of the polynom will be done by evalue(). The error will just be counted, if it is greater than the SAVE_BOUNDERY.

See also:
evalue()
Parameters:
vecInputthe data for wich the error is to evalue
maxYErrorthe maximum error, at which the evaluation should stop; if maxYError is 0 the maximum error is unlimeted
Returns:
the sum of the error of all datapoints, but maximal maxYError

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.

template<class tX, class tY>
virtual tY fib::algorithms::nD1::cPolynom< tX, tY >::evalueErrorMax ( const vector< cDataPointRange< tX, tY > > &  vecData,
const tY  maxYError 
) const
virtual

This method evalues the error of the given datapoints to the values this polynom evalues to. This function will stop the evaluation, if the maximum error maxYError was reached.

The evaluation of the polynom will be done by evalue(). A datapoint has an error, if it lay outside the datpoint range. The error is it's distance to the neares datapoint boundery. The error will just be counted, if it is greater than the SAVE_BOUNDERY.

See also:
evalue()
Parameters:
vecInputthe data for wich the error is to evalue
maxYErrorthe maximum error, at which the evaluation should stop; if maxYError is 0 the maximum error is unlimeted
Returns:
the sum of the error of all datapoints, but maximal maxYError

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.

template<class tX, class tY>
virtual tY fib::algorithms::nD1::cPolynom< tX, tY >::evalueGoodPolynom ( const vector< cDataPointRange< tX, tY > > &  vecInputData,
unsigned long  ulTimeNeed = 1024 
)
virtual

This method evalues the a good polynom, which matches the given range data vecData. For this a polynom which evalues a low error on the given data point ranges is evalued.

See also:
evalue()
Parameters:
vecInputDatathe data which the returend polynom should match
ulTimeNeeda value for the time, wich can be used to optimize the result, the (additional) evaluation time will scale linear with this factor
Returns:
the factors of the evalued polynom in this polynom and the error for the evalued polynom on the given data
template<class tX, class tY>
virtual unsigned long fib::algorithms::nD1::cPolynom< tX, tY >::evalueSpline ( const vector< cDataPointRange< tX, tY > > &  vecInputData,
unsigned int  uiNumberOfParameters = 4,
const unsigned int  uiMinBitsToStoreMantissa = 1,
const tY  maxValue = 1E+36,
const unsigned long  ulMaxMemoryCost = 0 
)
virtual

This functions evalues a spline, which matches the given range vecInputData The vector vecData is the sorted vector vecInputData. vecData The y value, to wich the spline evalues the x value, will be in the bound of the range data point, so that: vecData[i].minY <= spline( vecData[i].x ) <= vecData[i].maxY, for i = 0 till n, with n <= vecData.size() The first sorted n range data points will be matched by the spline. The first sorted n+1'th data points can't be matched by a spline/polynom with uiNumberOfParameters parameters. The evalued spline (this polynom) will have the form: y = vecFactors[ 0 ] + vecFactors[ 1 ] * x + vecFactors[ 2 ] * x^2 + ... + vecFactors[ uiNumberOfParameters - 1 ] * x^(uiNumberOfParameters - 1)

See also:
evalue()
evalueSplineIterativFast()
Parameters:
vecInputDatathe data which the returend polynom should match
uiNumberOfParametersthe number of parameters for the spline; Don't choose this number to big, because the evaluation time will grow exponentialy with this number. Even splines with 8 parameters will take some time.
uiMinBitsToStoreMantissathe minimal number of bits to store the mantissa of the parameters, when the parameter is in the form: mantissa * 2^exponent ; the method will try to reduce the bits, to store a parameter of the returned vector, to the uiMinBitsToStoreMantissa value; if uiMinBitsToStoreMantissa is 0, no optimization for the mantissa bits will be done
maxValuethe maximum possible value in all parameters the evalued polynom will allways have parameters vecFactors[i] with -1 * maxValue <= vecFactors[i] <= maxValue for 0 <= i < vecFactors.size()
ulMaxMemoryCosta number for the maximum memory cost this method is allowed to use; if 0 the maximum memory cost is unbounded
Returns:
the number n of data points vecData, which the spline matches; the sorted data points vecData[0] to vecData[ return - 1 ] will be matched by the spline
template<class tX, class tY>
virtual unsigned long fib::algorithms::nD1::cPolynom< tX, tY >::evalueSplineIterativFast ( const vector< cDataPointRange< tX, tY > > &  vecInputData,
unsigned int  uiMaxNumberOfParameters = 4,
const unsigned int  uiMinBitsToStoreMantissa = 1,
const tY  maxValue = 1E+36,
const tY  maxError = 0,
const unsigned long  ulMaxMemoryCost = 0 
)
virtual

This functions evalues a spline, which matches the given range data vecInputData The vector vecData is the sorted vector vecInputData. The y value, to wich the spline evalues the x value, will be in the bound of the range data point, so that: vecData[i].minY <= spline( vecData[i].x ) <= vecData[i].maxY, for i = 0 till n, with n <= vecData.size() The first sorted n range data points will be matched by the spline. The first sorted n+1'th data points can't be matched by a spline/polynom with uiNumberOfParameters parameters. The evalued spline (this polynom) will have the form: y = vecFactors[ 0 ] + vecFactors[ 1 ] * x + vecFactors[ 2 ] * x^2 + ... + vecFactors[ uiNumberOfParameters - 1 ] * x^(uiNumberOfParameters - 1)

The method should give the same result as evalueSpline() but faster. It will iterativ increase the number of parameters for the spline (from 1 to uiMaxNumberOfParameters) and will try to not use all of the given range points to find the polynom.

See also:
evalue()
evalueSpline()
Parameters:
vecInputDatathe data which the returend polynom should match
uiMaxNumberOfParametersthe number of parameters for the spline; Don't choose this number to big, because the evaluation time will grow exponentialy with this number. Even splines with 8 parameters will take some time.
uiMinBitsToStoreMantissathe minimal number of bits to store the mantissa of the parameters, when the parameter is in the form: mantissa * 2^exponent ; the method will try to reduce the bits, to store a parameter of the returned vector, to the uiMinBitsToStoreMantissa value; if uiMinBitsToStoreMantissa is 0, no optimization for the mantissa bits will be done
maxValuethe maximum possible value in all parameters the evalued polynom will allways have parameters vecFactors[i] with -1 * maxValue <= vecFactors[i] <= maxValue for 0 <= i < vecFactors.size()
maxErrorthe maximal error for the polynom to find; the error on the interpolated polynom for vecData will be equal or less than maxError
ulMaxMemoryCosta number for the maximum memory cost this method is allowed to use; if 0 the maximum memory cost is unbounded
Returns:
the number n of data points vecData, which the spline matches; the sorted data points vecData[0] to vecData[ return - 1 ] will be matched by the spline
template<class tX, class tY>
virtual tY fib::algorithms::nD1::cPolynom< tX, tY >::findFunctionRand ( const vector< cDataPointRange< tX, tY > > &  vecInputData,
unsigned long  ulMaxIterations = 256 *256 *256 
)
virtual

This method trys to find a polynom for the given data vecData by choosen n random points from vecData and create a polynom of order n for them. The number n will at the beginning be 1 and then canged random in an reange near the best found polynomorder till now. The creation of the polynom from random datapoints is tryed ulMaxIterations times and the polynom with the smales error on the data is returned.

See also:
evalue() for the type of the polynom
Parameters:
vecInputDatathe data which the returend polynom should match
ulMaxIterationsthe maximal number of iterations / polynoms to generate
Returns:
the error of the best found function and the values of the evalued polynom in this polynom
template<class tX, class tY>
long fib::algorithms::nD1::cPolynom< tX, tY >::getLastFactorIndexNotNull ( ) const
Returns:
the index of the last factor, wich is not 0. (counting from 0, eg. if 0 is return the polynom is constant)
template<class tX, class tY>
virtual bool fib::algorithms::nD1::cPolynom< tX, tY >::operator!= ( const cPolynom< tX, tY > &  polynom) const
virtual
Parameters:
dataPointthe polynom to compare this polynom with
Returns:
true if the given polynom is not equal to this, else false (
See also:
x,
y)
template<class tX, class tY>
virtual bool fib::algorithms::nD1::cPolynom< tX, tY >::operator== ( const cPolynom< tX, tY > &  polynom) const
virtual
Parameters:
dataPointthe polynom to compare this polynom with
Returns:
true if the given polynom is equal to this, else false (
See also:
x,
y)
template<class tX, class tY>
virtual void fib::algorithms::nD1::cPolynom< tX, tY >::print ( ostream &  outputStream) const
virtual

This method prints this polynom to the given stream.

Parameters:
outputStreamthe stream wher to print this polynom to

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.

template<class tX, class tY>
virtual cUnderFunction* fib::algorithms::nD1::cPolynom< tX, tY >::toFibUnderFunction ( cFibVariable pVariable) const
virtual

This method converts this polynom, into an fib -underfunction. Beware: You have to delete the returned fib -underfunction.

Parameters:
pVariablethe variable (x) for the polynom
Returns:
a pointer to the fib -underfunction, wich represents the same polynom as this polynom

Implements fib::algorithms::nD1::cOneAryFunction< tX, tY >.


Member Data Documentation

template<class tX, class tY>
vector< tY > fib::algorithms::nD1::cPolynom< tX, tY >::vecFactors

The factors for the polynom.

See also:
evalue()

Definition at line 77 of file cPolynom.h.


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