cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nmrBernsteinPolynomial.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Ofri Sadowsky
7  Created on: 2001-10-17
8 
9  (C) Copyright 2001-2007 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 
22 #ifndef _nmrBernsteinPolynomial_h
23 #define _nmrBernsteinPolynomial_h
24 
26 
27 #include <assert.h>
28 
30 
67 {
68 public:
70 
71  typedef std::pair<nmrPolynomialBase::CoefficientType,
73 
74 #ifdef CISST_COMPILER_IS_MSVC
75 #pragma warning(push)
76 #pragma warning(disable:4996)
77 #endif // ifdef CISST_COMPILER_IS_MSVC
78 
90  : BaseType(numVariables, degree, degree)
92  , PowerBasis(numVariables, degree, numVariables - 1)
93 #endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
94  {
95 #if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
96  VariablePowers = &PowerBasis;
97 #endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
98  }
99 
100 #if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
101 
107  virtual void CISST_DEPRECATED SetVariables(const VariableType values[])
108  {
109  PowerBasis.SetVariables(values);
110  }
111 
115  virtual void CISST_DEPRECATED SetVariable(VariableIndexType varIndex, VariableType value)
116  {
117  PowerBasis.SetVariable(varIndex, value);
118  }
119 
120 
121  virtual bool CISST_DEPRECATED CanSetVariable(VariableIndexType varIndex) const
122  {
123  return ( (0 <= varIndex) &&
124  (varIndex < GetNumVariables()) &&
125  (varIndex != GetImplicitVarIndex()) );
126  }
127 
129  VariableType CISST_DEPRECATED GetImplicitVariable() const
130  {
131  return PowerBasis.GetImplicitVariable();
132  }
133 
135  VariableIndexType CISST_DEPRECATED GetImplicitVarIndex() const
136  {
137  return PowerBasis.GetImplicitVarIndex();
138  }
139 
141  void CISST_DEPRECATED SetImplicitVarIndex(VariableIndexType newIndex)
142  {
143  PowerBasis.SetImplicitVarIndex(newIndex);
144  }
145 #ifdef CISST_COMPILER_IS_MSVC
146 #pragma warning(pop)
147 #endif // ifdef CISST_COMPILER_IS_MSVC
148 #endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
149 
152  virtual InsertStatus SetCoefficient(const nmrPolynomialTermPowerIndex & where,
153  CoefficientType coefficient);
154 
157  virtual InsertStatus SetCoefficient(TermIteratorType & where, CoefficientType coefficient);
158 
160  virtual CoefficientType GetCoefficient(const nmrPolynomialTermPowerIndex & where) const;
161 
164  { return GetTermCoefficient(where); }
165  virtual CoefficientType GetCoefficient(const TermIteratorType & where) const
166  { return GetTermCoefficient(where); }
167 
171  virtual void RemoveTerm(TermIteratorType & where);
172 
177  virtual void Clear();
178 
182  virtual ValueType EvaluateBasis(const nmrPolynomialTermPowerIndex & where,
183  const nmrMultiVariablePowerBasis & variables) const;
184  virtual ValueType EvaluateBasis(const TermConstIteratorType & where,
185  const nmrMultiVariablePowerBasis & variables) const;
186  virtual ValueType EvaluateBasis(const TermIteratorType & where,
187  const nmrMultiVariablePowerBasis & variables) const;
188 
193  virtual void SerializeTermInfo(std::ostream & output, const TermConstIteratorType & termIterator) const;
194 
201  virtual void DeserializeTermInfo(std::istream & input, TermIteratorType & termIterator);
202 
209  virtual void AddConstant(CoefficientType shiftAmount);
210 
216  virtual void AddConstantToCoefficients(CoefficientType coefficients[],
217  CoefficientType shiftAmount) const;
218 
221  {
222  return ((BernsteinTermInfo *)(where->second))->second;
223  }
224 
227  {
228  return ((BernsteinTermInfo *)(where->second))->second;
229  }
230 
231 
232 protected:
235  {
236  return ((BernsteinTermInfo *)(where->second))->second;
237  }
238 
240  {
241  return ((BernsteinTermInfo *)(where->second))->first;
242  }
243 
245  {
246  return ((BernsteinTermInfo *)(where->second))->first;
247  }
248 
250  {
251  return ((BernsteinTermInfo *)(where->second))->first;
252  }
253 
254 #if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
256 #endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
257 
258 };
259 
260 
261 #endif // _nmrBernsteinPolynomial_h
262 
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
TermContainerType::iterator TermIteratorType
Definition: nmrPolynomialContainer.h:74
const nmrPolynomialTermPowerIndex::MultinomialCoefficientType & GetMultinomialCoefficient(const TermIteratorType &where) const
Definition: nmrBernsteinPolynomial.h:220
virtual void AddConstant(CoefficientType shiftAmount)=0
const CoefficientType & GetTermCoefficient(const TermConstIteratorType &where) const
Definition: nmrBernsteinPolynomial.h:239
const CoefficientType & GetTermCoefficient(const TermIteratorType &where) const
Definition: nmrBernsteinPolynomial.h:244
#define CISST_DEPRECATED
Definition: cmnPortability.h:310
VariableIndexType GetNumVariables() const
Definition: nmrPolynomialBase.h:69
virtual void SerializeTermInfo(std::ostream &output, const TermConstIteratorType &termIterator) const =0
Definition: nmrBernsteinPolynomial.h:66
virtual void DeserializeTermInfo(std::istream &input, TermIteratorType &termIterator)=0
nmrPolynomialTermPowerIndex::PowerType PowerType
Definition: nmrPolynomialBase.h:58
TermContainerType::const_iterator TermConstIteratorType
Definition: nmrPolynomialContainer.h:75
virtual void AddConstantToCoefficients(CoefficientType coefficients[], CoefficientType shiftAmount) const =0
virtual ValueType EvaluateBasis(const TermConstIteratorType &where, const nmrMultiVariablePowerBasis &variables) const =0
virtual InsertStatus SetCoefficient(const nmrPolynomialTermPowerIndex &where, CoefficientType coefficient)=0
nmrPolynomialTermPowerIndex::MultinomialCoefficientType & RefMultinomialCoefficient(const TermIteratorType &where)
Definition: nmrBernsteinPolynomial.h:234
virtual CoefficientType GetCoefficient(const TermConstIteratorType &where) const
Definition: nmrBernsteinPolynomial.h:163
virtual CoefficientType GetCoefficient(const TermIteratorType &where) const
Definition: nmrBernsteinPolynomial.h:165
BarycentricBasis(VariableIndexType numVariables, PowerType maxPower, VariableIndexType implicitVarIndex=-1)
Definition: nmrDynAllocPolynomialContainer.h:28
double CoefficientType
Definition: nmrPolynomialBase.h:56
nmrPolynomialTermPowerIndex::VariableIndexType VariableIndexType
Definition: nmrPolynomialBase.h:57
nmrBernsteinPolynomial(VariableIndexType numVariables, PowerType degree)
Definition: nmrBernsteinPolynomial.h:89
virtual CoefficientType GetCoefficient(const TermConstIteratorType &where) const =0
virtual void Clear()
Definition: nmrPolynomialContainer.h:291
unsigned long MultinomialCoefficientType
Definition: nmrPolynomialTermPowerIndex.h:101
Definition: nmrMultiVariablePowerBasis.h:37
std::pair< nmrPolynomialBase::CoefficientType, nmrPolynomialTermPowerIndex::MultinomialCoefficientType > BernsteinTermInfo
Definition: nmrBernsteinPolynomial.h:72
virtual void RemoveTerm(const nmrPolynomialTermPowerIndex &where)
Definition: nmrPolynomialContainer.h:276
Represents the power index of a single term in a multi-variable polynomial.
Definition: nmrPolynomialTermPowerIndex.h:89
CoefficientType & RefTermCoefficient(const TermIteratorType &where)
Definition: nmrBernsteinPolynomial.h:249
Rules of exporting.
nmrDynAllocPolynomialContainer BaseType
Definition: nmrBernsteinPolynomial.h:69
const nmrPolynomialTermPowerIndex::MultinomialCoefficientType & GetMultinomialCoefficient(const TermConstIteratorType &where) const
Definition: nmrBernsteinPolynomial.h:226
#define INCLUDE_DEPRECATED_POLYNOMIAL_CODE
Definition: nmrPolynomialBase.h:37