22 #ifndef _nmrPolynomialBase_h
23 #define _nmrPolynomialBase_h
37 #define INCLUDE_DEPRECATED_POLYNOMIAL_CODE 0
61 enum InsertStatus { INSERT_FAIL = -1, INSERT_NEW = 0, INSERT_REPLACE = 1 };
64 nmrPolynomialBase(VariableIndexType numVariables, PowerType minDegree, PowerType maxDegree);
85 virtual TermCounterType GetNumberOfTerms()
const = 0;
94 #if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
103 virtual void CISST_DEPRECATED SetVariable(VariableIndexType varIndex, VariableType value) = 0;
107 virtual bool CISST_DEPRECATED CanSetVariable(VariableIndexType varIndex)
const = 0;
109 #ifdef CISST_COMPILER_IS_MSVC
110 #pragma warning(push)
111 #pragma warning(disable:4996)
112 #endif // ifdef CISST_COMPILER_IS_MSVC
117 for (v = 0; v < GetNumVariables(); ++v)
118 vars[v] = GetVariable(v);
124 return VariablePowers->GetVariable(var);
128 VariableType
CISST_DEPRECATED GetVariablePower(VariableIndexType var, PowerType power)
const
130 return VariablePowers->GetVariablePower(var, power);
133 #ifdef CISST_COMPILER_IS_MSVC
135 #endif // ifdef CISST_COMPILER_IS_MSVC
136 #endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
140 virtual bool IsEmpty()
const = 0;
147 virtual void SetMinDegree(PowerType newMin)
throw(std::runtime_error) = 0;
155 virtual void SetMaxDegree(PowerType newMax)
throw(std::runtime_error) = 0;
160 virtual void FillAllTerms() = 0;
183 virtual void Clear() = 0;
201 virtual void CollectCoefficients(CoefficientType source[])
const = 0;
207 virtual void RestoreCoefficients(
const CoefficientType source[]) = 0;
209 #if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
210 #ifdef CISST_COMPILER_IS_MSVC
211 #pragma warning(push)
212 #pragma warning(disable:4996)
213 #endif // ifdef CISST_COMPILER_IS_MSVC
219 return VariablePowers->EvaluatePowerProduct(where.
GetPowers());
223 ValueType
CISST_DEPRECATED EvaluatePowerProduct(
const PowerType powers[])
const
225 return VariablePowers->EvaluatePowerProduct(powers);
238 return EvaluateBasis(where, *VariablePowers);
246 CoefficientType coefficient = GetCoefficient(where);
247 return EvaluateTerm(where, coefficient);
256 return EvaluateTerm(where, *VariablePowers, coefficient);
264 EvaluateBasisVector(*VariablePowers, termBaseValues);
271 return Evaluate(*VariablePowers);
280 ValueType
CISST_DEPRECATED EvaluateForCoefficients(
const CoefficientType coefficients[])
const
282 return EvaluateForCoefficients(*VariablePowers, coefficients);
284 #ifdef CISST_COMPILER_IS_MSVC
286 #endif // ifdef CISST_COMPILER_IS_MSVC
287 #endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
308 return EvaluateTerm(where, variables, coefficient);
318 if (coefficient == 0)
320 return coefficient * EvaluateBasis(where, variables);
328 ValueType termBaseValues[])
const = 0;
339 const CoefficientType coefficients[])
const = 0;
349 virtual void Scale(CoefficientType scaleFactor) = 0;
369 void CISST_DEPRECATED ScaleCoefficients(CoefficientType coefficients[], CoefficientType scaleFactor)
const;
382 virtual void AddConstant(CoefficientType shiftAmount) = 0;
403 virtual void AddConstantToCoefficients(CoefficientType coefficients[],
404 CoefficientType shiftAmount)
const = 0;
406 #if DEFINE_FORMATTED_OUTPUT
409 virtual char * Format(
char * buffer)
const = 0;
412 #if DEFINE_FORMATTED_OUTPUT
413 int CalculateFormatLength()
const
416 int coefficientLength = 15;
418 int termLength = coefficientLength + 1 + 2 + termPowerLength + 3;
419 int numTerms = GetNumberOfTerms();
420 return numTerms * termLength;
425 virtual void SerializeRaw(std::ostream & output)
const;
428 virtual void DeserializeRaw(std::istream & input);
435 #if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
437 #endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
443 #endif // _nmrPolynomialBase_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
#define CMN_ASSERT(expr)
Definition: cmnAssert.h:90
nmrPolynomialTermPowerIndex::MultinomialCoefficientType TermCounterType
Definition: nmrPolynomialBase.h:59
#define CISST_DEPRECATED
Definition: cmnPortability.h:310
VariableIndexType GetNumVariables() const
Definition: nmrPolynomialBase.h:69
TermCounterType GetMaxNumberOfTerms() const
Definition: nmrPolynomialBase.h:89
Portability across compilers and operating systems tools.
#define CMN_UNUSED(argument)
Definition: cmnPortability.h:479
PowerType MinDegree
Definition: nmrPolynomialBase.h:432
double ValueType
Definition: nmrPolynomialBase.h:54
virtual CoefficientType GetCoefficient(const nmrPolynomialTermPowerIndex &CMN_UNUSED(where)) const
Definition: nmrPolynomialBase.h:191
int VariableIndexType
Definition: nmrPolynomialTermPowerIndex.h:95
Definition: nmrPolynomialBase.h:51
nmrPolynomialTermPowerIndex::PowerType PowerType
Definition: nmrPolynomialBase.h:58
PowerType MaxDegree
Definition: nmrPolynomialBase.h:433
int PowerType
Definition: nmrPolynomialTermPowerIndex.h:98
PowerType GetMaxDegree() const
Definition: nmrPolynomialBase.h:79
double VariableType
Definition: nmrPolynomialBase.h:55
VariableIndexType NumVariables
Definition: nmrPolynomialBase.h:431
ValueType EvaluateTerm(const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables, CoefficientType coefficient) const
Definition: nmrPolynomialBase.h:315
double CoefficientType
Definition: nmrPolynomialBase.h:56
ValueType EvaluateTerm(const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables) const
Definition: nmrPolynomialBase.h:304
virtual ~nmrPolynomialBase()
Definition: nmrPolynomialBase.h:66
nmrPolynomialTermPowerIndex::VariableIndexType VariableIndexType
Definition: nmrPolynomialBase.h:57
PowerType GetMinDegree() const
Definition: nmrPolynomialBase.h:74
const PowerType * GetPowers() const
Definition: nmrPolynomialTermPowerIndex.h:181
unsigned long MultinomialCoefficientType
Definition: nmrPolynomialTermPowerIndex.h:101
Definition: nmrMultiVariablePowerBasis.h:37
Declare class nmrPolynomialTermPowerIndex to represent the power index of a single term in a multi-va...
Represents the power index of a single term in a multi-variable polynomial.
Definition: nmrPolynomialTermPowerIndex.h:89
InsertStatus
Definition: nmrPolynomialBase.h:61