cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
nmrPolynomialBase Class Referenceabstract

#include <nmrPolynomialBase.h>

Inheritance diagram for nmrPolynomialBase:
nmrPolynomialContainer< _TermInfo > nmrPolynomialContainer< void * > nmrDynAllocPolynomialContainer nmrBernsteinPolynomial nmrStandardPolynomial

Public Types

enum  InsertStatus { INSERT_FAIL = -1, INSERT_NEW = 0, INSERT_REPLACE = 1 }
 
typedef double ValueType
 
typedef double VariableType
 
typedef double CoefficientType
 
typedef
nmrPolynomialTermPowerIndex::VariableIndexType 
VariableIndexType
 
typedef
nmrPolynomialTermPowerIndex::PowerType 
PowerType
 
typedef
nmrPolynomialTermPowerIndex::MultinomialCoefficientType 
TermCounterType
 

Public Member Functions

 nmrPolynomialBase (VariableIndexType numVariables, PowerType minDegree, PowerType maxDegree)
 
virtual ~nmrPolynomialBase ()
 
VariableIndexType GetNumVariables () const
 
PowerType GetMinDegree () const
 
PowerType GetMaxDegree () const
 
virtual TermCounterType GetNumberOfTerms () const =0
 
TermCounterType GetMaxNumberOfTerms () const
 
virtual bool IsEmpty () const =0
 
virtual void SetMinDegree (PowerType newMin)=0 throw (std::runtime_error)
 
virtual void SetMaxDegree (PowerType newMax)=0 throw (std::runtime_error)
 
virtual void FillAllTerms ()=0
 
bool CanIncludeIndex (const nmrPolynomialTermPowerIndex &term) const
 
virtual bool IncludesIndex (const nmrPolynomialTermPowerIndex &target) const =0
 
virtual TermCounterType GetIndexPosition (const nmrPolynomialTermPowerIndex &term) const =0
 
virtual void RemoveTerm (const nmrPolynomialTermPowerIndex &where)=0
 
virtual void Clear ()=0
 
virtual InsertStatus SetCoefficient (const nmrPolynomialTermPowerIndex &where, CoefficientType coefficient)=0
 
virtual CoefficientType GetCoefficient (const nmrPolynomialTermPowerIndex &CMN_UNUSED(where)) const
 
virtual void CollectCoefficients (CoefficientType source[]) const =0
 
virtual void RestoreCoefficients (const CoefficientType source[])=0
 
virtual ValueType EvaluateBasis (const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables) const =0
 
ValueType EvaluateTerm (const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables) const
 
ValueType EvaluateTerm (const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables, CoefficientType coefficient) const
 
virtual void EvaluateBasisVector (const nmrMultiVariablePowerBasis &variables, ValueType termBaseValues[]) const =0
 
virtual ValueType EvaluateForCoefficients (const nmrMultiVariablePowerBasis &variables, const CoefficientType coefficients[]) const =0
 
virtual ValueType Evaluate (const nmrMultiVariablePowerBasis &variables) const =0
 
virtual void Scale (CoefficientType scaleFactor)=0
 
void CISST_DEPRECATED ScaleCoefficients (CoefficientType coefficients[], CoefficientType scaleFactor) const
 
virtual void AddConstant (CoefficientType shiftAmount)=0
 
virtual void AddConstantToCoefficients (CoefficientType coefficients[], CoefficientType shiftAmount) const =0
 
virtual void SerializeRaw (std::ostream &output) const
 
virtual void DeserializeRaw (std::istream &input)
 

Protected Attributes

VariableIndexType NumVariables
 
PowerType MinDegree
 
PowerType MaxDegree
 

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
INSERT_FAIL 
INSERT_NEW 
INSERT_REPLACE 

Constructor & Destructor Documentation

nmrPolynomialBase::nmrPolynomialBase ( VariableIndexType  numVariables,
PowerType  minDegree,
PowerType  maxDegree 
)
virtual nmrPolynomialBase::~nmrPolynomialBase ( )
inlinevirtual

Member Function Documentation

virtual void nmrPolynomialBase::AddConstant ( CoefficientType  shiftAmount)
pure virtual

Add a constant value to this polynomial. That is, if p is a polynomial and s is a constant then the following returns true: ValueType v0 = p.Evaluate(); p.AddConstant(s); ValueType v1 = p.Evaluate(); v1 - v0 == s // up to floating point precision error

Note
the implementation varies between different representations of the polynomial. Specifically, terms may be added to this polynomial to support the addition of the constant.

Implemented in nmrPolynomialContainer< _TermInfo >, nmrPolynomialContainer< void * >, nmrBernsteinPolynomial, and nmrStandardPolynomial.

virtual void nmrPolynomialBase::AddConstantToCoefficients ( CoefficientType  coefficients[],
CoefficientType  shiftAmount 
) const
pure virtual

Modify external coefficients so that they evaluate a new polynomial shifted by a constant amount. That is, if p is a polynomial, c is an array of external coefficients, and s is a constant, the following returns true: ValueType v0 = p.EvaluateForCoefficients(c); p.AddConstantToCoefficients(c, s); ValueType v1 = p.EvaluateForCoefficients(c); v1 - v0 == s; // up to floating point precision error

Note
The implementation of this function may vary based on the representation of the polynomial. In particular, for a Bernstein polynomial it requires that all possible terms be present in the polynomial and in the coefficients correspondingly. For a standard polynomial, it requires that this polynomial actually contains a term of power zero.
The current implementations assert that this polynomial and the external coefficients meet the preconditions for the operation. That is, we do not throw an exception but rather issue an assertion error.

Implemented in nmrPolynomialContainer< _TermInfo >, nmrPolynomialContainer< void * >, nmrBernsteinPolynomial, and nmrStandardPolynomial.

bool nmrPolynomialBase::CanIncludeIndex ( const nmrPolynomialTermPowerIndex term) const
virtual void nmrPolynomialBase::Clear ( )
pure virtual
virtual void nmrPolynomialBase::CollectCoefficients ( CoefficientType  source[]) const
pure virtual
virtual void nmrPolynomialBase::DeserializeRaw ( std::istream &  input)
virtual

Deserialize NumVariables, MinDegree, MaxDegree

Reimplemented in nmrPolynomialContainer< _TermInfo >, and nmrPolynomialContainer< void * >.

virtual ValueType nmrPolynomialBase::Evaluate ( const nmrMultiVariablePowerBasis variables) const
pure virtual

Evaluate the polynomial for externally given variables

Implemented in nmrPolynomialContainer< _TermInfo >, and nmrPolynomialContainer< void * >.

virtual ValueType nmrPolynomialBase::EvaluateBasis ( const nmrPolynomialTermPowerIndex where,
const nmrMultiVariablePowerBasis variables 
) const
pure virtual

Evaluate the basis function for a term. The term is regarded as a list of powers, without any user defined coefficient. However, for different families of polynomial the set of basis functions are different. For example, Bezier polynomials have the multinomial coefficient in addition to each user defined coefficient. Implemented for each concrete polynomial class.

Implemented in nmrBernsteinPolynomial, and nmrStandardPolynomial.

virtual void nmrPolynomialBase::EvaluateBasisVector ( const nmrMultiVariablePowerBasis variables,
ValueType  termBaseValues[] 
) const
pure virtual

Evaluate the basis vector for extrnally given variables. Evaluate the basis function for each terms in the polynomial, and store the results into an array of termBaseValues.

Implemented in nmrPolynomialContainer< _TermInfo >, and nmrPolynomialContainer< void * >.

virtual ValueType nmrPolynomialBase::EvaluateForCoefficients ( const nmrMultiVariablePowerBasis variables,
const CoefficientType  coefficients[] 
) const
pure virtual

Evaluate the polynomial at the currently specified point, using externally defined coefficients. This lets the user create many polynomials over the same set of basis functions without having to duplicate the terms. The input coefficients must be ordered the same way as the terms in this object. It is best to order them using CollectCoefficients()

Implemented in nmrPolynomialContainer< _TermInfo >, and nmrPolynomialContainer< void * >.

ValueType nmrPolynomialBase::EvaluateTerm ( const nmrPolynomialTermPowerIndex where,
const nmrMultiVariablePowerBasis variables 
) const
inline

Evaluate a single term at the point specified by the `variables' argument, including the basis function and the term's coefficient. This function uses the internally stored coefficient.

ValueType nmrPolynomialBase::EvaluateTerm ( const nmrPolynomialTermPowerIndex where,
const nmrMultiVariablePowerBasis variables,
CoefficientType  coefficient 
) const
inline

Evaluate a single term at the point specified by the `variables' argument, including the basis function and the term's coefficient. This function takes the coefficient as a parameter.

virtual void nmrPolynomialBase::FillAllTerms ( )
pure virtual
virtual CoefficientType nmrPolynomialBase::GetCoefficient ( const nmrPolynomialTermPowerIndex CMN_UNUSEDwhere) const
inlinevirtual
virtual TermCounterType nmrPolynomialBase::GetIndexPosition ( const nmrPolynomialTermPowerIndex term) const
pure virtual
PowerType nmrPolynomialBase::GetMaxDegree ( ) const
inline
TermCounterType nmrPolynomialBase::GetMaxNumberOfTerms ( ) const
inline
PowerType nmrPolynomialBase::GetMinDegree ( ) const
inline
virtual TermCounterType nmrPolynomialBase::GetNumberOfTerms ( ) const
pure virtual
VariableIndexType nmrPolynomialBase::GetNumVariables ( ) const
inline
virtual bool nmrPolynomialBase::IncludesIndex ( const nmrPolynomialTermPowerIndex target) const
pure virtual
virtual bool nmrPolynomialBase::IsEmpty ( ) const
pure virtual
virtual void nmrPolynomialBase::RemoveTerm ( const nmrPolynomialTermPowerIndex where)
pure virtual
virtual void nmrPolynomialBase::RestoreCoefficients ( const CoefficientType  source[])
pure virtual
virtual void nmrPolynomialBase::Scale ( CoefficientType  scaleFactor)
pure virtual

Scale the polynomial by a given scalar value. Basically, it means multiplying all the term coefficient by the scale factor.

Implemented in nmrPolynomialContainer< _TermInfo >, and nmrPolynomialContainer< void * >.

void CISST_DEPRECATED nmrPolynomialBase::ScaleCoefficients ( CoefficientType  coefficients[],
CoefficientType  scaleFactor 
) const

Scale a given set of external coefficients which correspond to the terms of this polynomial. Basically, it means multiplying them all by the scale factor.

Parameters
coefficients[i/o] the external coefficients to be scales (in place).
scaleFactorthe scaling factor.
Note
this function is not declared virtual, as it seems to behave uniformly for all types of polynomial representations we use. But it may have to be declared virtual eventually. Technically, it could be declared static, but I find it too far fetched.
The same rules that apply to evaluating the polynomial for external coefficients apply here as well.
the function is declared as deprecated. Generally, using the Multiply operation on cisstVector containers of coefficients should be prefered.
virtual void nmrPolynomialBase::SerializeRaw ( std::ostream &  output) const
virtual

Serialize NumVariables, MinDegree, MaxDegree

Reimplemented in nmrPolynomialContainer< _TermInfo >, and nmrPolynomialContainer< void * >.

virtual InsertStatus nmrPolynomialBase::SetCoefficient ( const nmrPolynomialTermPowerIndex where,
CoefficientType  coefficient 
)
pure virtual
virtual void nmrPolynomialBase::SetMaxDegree ( PowerType  newMax)
throw (std::runtime_error
)
pure virtual
virtual void nmrPolynomialBase::SetMinDegree ( PowerType  newMin)
throw (std::runtime_error
)
pure virtual

Member Data Documentation

PowerType nmrPolynomialBase::MaxDegree
protected
PowerType nmrPolynomialBase::MinDegree
protected
VariableIndexType nmrPolynomialBase::NumVariables
protected

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