27 #ifndef _nmrPolynomialTermPowerIndex_h
28 #define _nmrPolynomialTermPowerIndex_h
41 #ifndef DEFINE_FORMATTED_OUTPUT
42 #define DEFINE_FORMATTED_OUTPUT 0
138 if (newMax < this->Degree) {
139 throw std::runtime_error(
"nmrPolynomialTermPowerIndex: Attempt to set max degree below current degree");
141 if (newMax < this->MinDegree) {
142 throw std::runtime_error(
"nmrPolynomialTermPowerIndex: Attempt to set max degree below set minimum");
149 if (newMin > this->Degree) {
150 throw std::runtime_error(
"nmrPolynomialTermPowerIndex: Attempt to set min degree above current degree");
152 if (newMin > this->MaxDegree) {
153 throw std::runtime_error(
"nmrPolynomialTermPowerIndex: Attempt to set max degree above set maximum");
163 return (MinDegree <= Degree) && (Degree <= MaxDegree);
168 return Powers.size();
177 return Powers[variable];
189 return reinterpret_cast<const int *
>(GetPowers());
198 Degree += power - Powers[variable];
199 Powers[variable] = power;
207 for (i = 0; i < GetNumVariables(); i++) {
208 Powers[i] = powers[i];
221 void SetDegree(PowerType degree);
261 return (GetDegree() == GetMinDegree()) && (GetPower(0) == GetMinDegree());
267 return (GetDegree() == GetMaxDegree()) && (GetPower(GetNumVariables() - 1) == GetMaxDegree());
292 return (this->Compare(other) < 0);
301 return (other < *
this);
306 return (this->Compare(other) <= 0);
311 return (other <= *
this);
328 static MultinomialCoefficientType
329 EvaluateMultinomialCoefficient(VariableIndexType numIndices,
330 PowerType chooseFrom,
const PowerType indices[]);
335 static MultinomialCoefficientType
336 EvaluateMultinomialCoefficient(VariableIndexType numIndices,
337 const PowerType indices[]);
345 return EvaluateMultinomialCoefficient(GetNumVariables(), GetPowers());
354 return EvaluateMultinomialCoefficient(GetNumVariables(), d, GetPowers());
382 MultinomialCoefficientType CountPowerCombinations()
const;
387 MultinomialCoefficientType CountLowerOrderTerms()
const;
389 #if DEFINE_FORMATTED_OUTPUT
398 char * FormatPowers(
char * buffer,
const char * widthFormat =
"%d")
const;
402 #if DEFINE_FORMATTED_OUTPUT
406 char * FormatTermIndex(
char * buffer,
const char * widthFormat =
"%d")
const;
409 #if DEFINE_FORMATTED_OUTPUT
412 int CalculateFormatPowerLength(
const char * widthFormat =
"%d")
const
415 sprintf( buff, widthFormat, GetMaxDegree() );
416 int varLength = strlen(buff) + 1;
417 return varLength * GetNumVariables();
426 void SerializeRaw(std::ostream & output)
const;
431 void DeserializeRaw(std::istream & input);
438 void SerializeIndexRaw(std::ostream & output)
const;
442 void DeserializeIndexRaw(std::istream & input);
457 #endif // _nmrPolynomialTermPowerIndex_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
int Degree
Definition: nmrPolynomialTermPowerIndex.h:453
MultinomialCoefficientType GetMultinomialCoefficient() const
Definition: nmrPolynomialTermPowerIndex.h:343
std::vector< PowerType > Powers
Definition: nmrPolynomialTermPowerIndex.h:445
Portability across compilers and operating systems tools.
MultinomialCoefficientType GetMultinomialCoefficient(PowerType d) const
Definition: nmrPolynomialTermPowerIndex.h:352
const int * GetPowersAsSigned() const
Definition: nmrPolynomialTermPowerIndex.h:187
PowerType MaxDegree
Definition: nmrPolynomialTermPowerIndex.h:447
void SetPower(VariableIndexType variable, PowerType power)
Definition: nmrPolynomialTermPowerIndex.h:196
int VariableIndexType
Definition: nmrPolynomialTermPowerIndex.h:95
PowerType MinDegree
Definition: nmrPolynomialTermPowerIndex.h:446
Definition: nmrPolynomialBase.h:51
PowerType GetMinDegree() const
Definition: nmrPolynomialTermPowerIndex.h:131
VariableIndexType GetNumVariables() const
Definition: nmrPolynomialTermPowerIndex.h:166
int PowerType
Definition: nmrPolynomialTermPowerIndex.h:98
bool IsEnd() const
Definition: nmrPolynomialTermPowerIndex.h:265
void SetPowers(const PowerType powers[])
Definition: nmrPolynomialTermPowerIndex.h:203
void SetMaxDegree(PowerType newMax)
Definition: nmrPolynomialTermPowerIndex.h:136
int GetDegree() const
Definition: nmrPolynomialTermPowerIndex.h:121
PowerType GetMaxDegree() const
Definition: nmrPolynomialTermPowerIndex.h:126
void SetMinDegree(PowerType newMin)
Definition: nmrPolynomialTermPowerIndex.h:147
PowerType GetPower(VariableIndexType variable) const
Definition: nmrPolynomialTermPowerIndex.h:175
bool IsValid() const
Definition: nmrPolynomialTermPowerIndex.h:161
bool IsBegin() const
Definition: nmrPolynomialTermPowerIndex.h:259
const PowerType * GetPowers() const
Definition: nmrPolynomialTermPowerIndex.h:181
unsigned long MultinomialCoefficientType
Definition: nmrPolynomialTermPowerIndex.h:101
Represents the power index of a single term in a multi-variable polynomial.
Definition: nmrPolynomialTermPowerIndex.h:89