22#ifndef _nmrPolynomialBase_h
23#define _nmrPolynomialBase_h
37#define INCLUDE_DEPRECATED_POLYNOMIAL_CODE 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
111#pragma warning(disable:4996)
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
209#if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
210#ifdef CISST_COMPILER_IS_MSVC
212#pragma warning(disable:4996)
219 return VariablePowers->EvaluatePowerProduct(where.
GetPowers());
223 ValueType
CISST_DEPRECATED EvaluatePowerProduct(
const PowerType powers[])
const
225 return VariablePowers->EvaluatePowerProduct(powers);
244 ValueType
CISST_DEPRECATED EvaluateTerm(
const nmrPolynomialTermPowerIndex & where)
const
247 return EvaluateTerm(where, coefficient);
254 ValueType
CISST_DEPRECATED EvaluateTerm(
const nmrPolynomialTermPowerIndex & where, CoefficientType coefficient)
const
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
308 return EvaluateTerm(where, variables, coefficient);
318 if (coefficient == 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;
420 return numTerms * termLength;
435#if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
Definition nmrMultiVariablePowerBasis.h:38
virtual void CollectCoefficients(CoefficientType source[]) const =0
virtual void AddConstant(CoefficientType shiftAmount)=0
virtual ~nmrPolynomialBase()
Definition nmrPolynomialBase.h:66
virtual ValueType Evaluate(const nmrMultiVariablePowerBasis &variables) const =0
virtual ValueType EvaluateForCoefficients(const nmrMultiVariablePowerBasis &variables, const CoefficientType coefficients[]) const =0
PowerType MinDegree
Definition nmrPolynomialBase.h:432
PowerType MaxDegree
Definition nmrPolynomialBase.h:433
virtual bool IncludesIndex(const nmrPolynomialTermPowerIndex &target) const =0
virtual void SerializeRaw(std::ostream &output) const
nmrPolynomialTermPowerIndex::MultinomialCoefficientType TermCounterType
Definition nmrPolynomialBase.h:59
VariableIndexType GetNumVariables() const
Definition nmrPolynomialBase.h:69
nmrPolynomialTermPowerIndex::PowerType PowerType
Definition nmrPolynomialBase.h:58
virtual void DeserializeRaw(std::istream &input)
virtual CoefficientType GetCoefficient(const nmrPolynomialTermPowerIndex &CMN_UNUSED(where)) const
Definition nmrPolynomialBase.h:191
double VariableType
Definition nmrPolynomialBase.h:55
virtual TermCounterType GetNumberOfTerms() const =0
void CISST_DEPRECATED ScaleCoefficients(CoefficientType coefficients[], CoefficientType scaleFactor) const
double ValueType
Definition nmrPolynomialBase.h:54
double CoefficientType
Definition nmrPolynomialBase.h:56
bool CanIncludeIndex(const nmrPolynomialTermPowerIndex &term) const
virtual void EvaluateBasisVector(const nmrMultiVariablePowerBasis &variables, ValueType termBaseValues[]) const =0
virtual void RestoreCoefficients(const CoefficientType source[])=0
TermCounterType GetMaxNumberOfTerms() const
Definition nmrPolynomialBase.h:89
virtual void virtual SetMinDegree(PowerType newMin) CISST_THROW(std void virtual SetMaxDegree(PowerType newMax) CISST_THROW(std void FillAllTerms()=0
PowerType GetMinDegree() const
Definition nmrPolynomialBase.h:74
nmrPolynomialTermPowerIndex::VariableIndexType VariableIndexType
Definition nmrPolynomialBase.h:57
virtual TermCounterType GetIndexPosition(const nmrPolynomialTermPowerIndex &term) const =0
virtual bool IsEmpty() const =0
InsertStatus
Definition nmrPolynomialBase.h:61
@ INSERT_FAIL
Definition nmrPolynomialBase.h:61
@ INSERT_NEW
Definition nmrPolynomialBase.h:61
@ INSERT_REPLACE
Definition nmrPolynomialBase.h:61
virtual InsertStatus SetCoefficient(const nmrPolynomialTermPowerIndex &where, CoefficientType coefficient)=0
virtual void AddConstantToCoefficients(CoefficientType coefficients[], CoefficientType shiftAmount) const =0
VariableIndexType NumVariables
Definition nmrPolynomialBase.h:431
virtual void RemoveTerm(const nmrPolynomialTermPowerIndex &where)=0
PowerType GetMaxDegree() const
Definition nmrPolynomialBase.h:79
virtual ValueType EvaluateBasis(const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables) const =0
nmrPolynomialBase(VariableIndexType numVariables, PowerType minDegree, PowerType maxDegree)
virtual void Scale(CoefficientType scaleFactor)=0
Represents the power index of a single term in a multi-variable polynomial.
Definition nmrPolynomialTermPowerIndex.h:90
unsigned long MultinomialCoefficientType
Definition nmrPolynomialTermPowerIndex.h:101
nmrPolynomialTermPowerIndex(VariableIndexType numVariables=1, PowerType minDegree=0, PowerType maxDegree=4)
int PowerType
Definition nmrPolynomialTermPowerIndex.h:98
int VariableIndexType
Definition nmrPolynomialTermPowerIndex.h:95
const PowerType * GetPowers() const
Definition nmrPolynomialTermPowerIndex.h:181
#define CMN_ASSERT(expr)
Definition cmnAssert.h:97
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Portability across compilers and operating systems tools.
#define CMN_UNUSED(argument)
Definition cmnPortability.h:497
#define CISST_DEPRECATED
Definition cmnPortability.h:314
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
virtual ValueType EvaluateBasis(const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables) const
virtual CoefficientType GetCoefficient(const nmrPolynomialTermPowerIndex &where) const
Declare class nmrPolynomialTermPowerIndex to represent the power index of a single term in a multi-va...