cisst-saw
Loading...
Searching...
No Matches
nmrStandardPolynomial.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: 2003
8
9 (C) Copyright 2003-2007 Johns Hopkins University (JHU), All Rights
10 Reserved.
11
12--- begin cisst license - do not edit ---
13
14This software is provided "as is" under an open source license, with
15no warranty. The complete license can be found in license.txt and
16http://www.cisst.org/cisst/license.txt.
17
18--- end cisst license ---
19*/
20
21
22#ifndef _nmrStandardPolynomial_h
23#define _nmrStandardPolynomial_h
24
25
28
29
56{
57public:
59
62 nmrStandardPolynomial(VariableIndexType numVariables, PowerType minDegree, PowerType maxDegree)
63 : BaseType(numVariables, minDegree, maxDegree)
65 , PowerBasis(numVariables, maxDegree)
66#endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
67
68 {
69#if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
70#ifdef CISST_COMPILER_IS_MSVC
71#pragma warning(push)
72#pragma warning(disable:4996)
73#endif // ifdef CISST_COMPILER_IS_MSVC
74 VariablePowers = &PowerBasis;
75#ifdef CISST_COMPILER_IS_MSVC
76#pragma warning(pop)
77#endif // ifdef CISST_COMPILER_IS_MSVC
78#endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
79 }
80
82 {}
83
84#if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
85#ifdef CISST_COMPILER_IS_MSVC
86#pragma warning(push)
87#pragma warning(disable:4996)
88#endif // ifdef CISST_COMPILER_IS_MSVC
89 virtual void CISST_DEPRECATED SetVariable(VariableIndexType varIndex, VariableType value);
90
91 virtual void CISST_DEPRECATED SetVariables(const VariableType vars[]);
92
93 virtual bool CISST_DEPRECATED CanSetVariable(VariableIndexType varIndex) const
94 {
95 return ( (0 <= varIndex) && (varIndex < GetNumVariables()) );
96 }
97#ifdef CISST_COMPILER_IS_MSVC
98#pragma warning(pop)
99#endif // ifdef CISST_COMPILER_IS_MSVC
100#endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
101
104
106 {
107 DereferenceIterator(where) = coefficient;
108 return INSERT_REPLACE;
109 }
110
111
114 {
116
117 return (it != EndTermIterator())
119 : 0;
120 }
121
123 {
124 return DereferenceConstIterator(where);
125 }
126
128 {
129 return DereferenceConstIterator(where);
130 }
131
132
133
137 virtual void RemoveTerm(TermIteratorType & where);
138
143 virtual void Clear();
144
146 const nmrMultiVariablePowerBasis & variables) const
147 {
148 assert(where.GetNumVariables() == variables.GetNumVariables());
149 assert(where.GetDegree() <= variables.GetMaxDegree());
150 return variables.EvaluatePowerProduct(where.GetPowers());
151 }
152
154 const nmrMultiVariablePowerBasis & variables) const
155 {
156 return EvaluateBasis( where->first, variables );
157 }
158
160 const nmrMultiVariablePowerBasis & variables) const
161 {
162 return EvaluateBasis( where->first, variables );
163 }
164
169 virtual void SerializeTermInfo(std::ostream & output, const TermConstIteratorType & termIterator) const;
170
175 virtual void DeserializeTermInfo(std::istream & input, TermIteratorType & termIterator);
176
181 virtual void AddConstant(CoefficientType shiftAmount);
182
188 virtual void AddConstantToCoefficients(CoefficientType coefficients[],
189 CoefficientType shiftAmount) const;
190
191protected:
192
194 {
195 CoefficientType * pCoeff = (CoefficientType *)(it->second);
196 return *pCoeff;
197 }
198
200 { return *((CoefficientType *)(it->second)); }
201
203 { return *((CoefficientType *)(it->second)); }
204
205#if INCLUDE_DEPRECATED_POLYNOMIAL_CODE
207#endif // INCLUDE_DEPRECATED_POLYNOMIAL_CODE
208
209};
210
211
212#endif // _nmrStandardPolynomial_h
213
nmrDynAllocPolynomialContainer(unsigned int numVariables, unsigned int minDegree, unsigned int maxDegree)
Definition nmrDynAllocPolynomialContainer.h:33
Definition nmrMultiVariablePowerBasis.h:143
Definition nmrMultiVariablePowerBasis.h:38
ValueType EvaluatePowerProduct(const PowerType powers[]) const
PowerType GetMaxDegree() const
Definition nmrMultiVariablePowerBasis.h:69
VariableIndexType GetNumVariables() const
Definition nmrMultiVariablePowerBasis.h:64
nmrPolynomialTermPowerIndex::PowerType PowerType
Definition nmrPolynomialBase.h:58
double ValueType
Definition nmrPolynomialBase.h:54
double CoefficientType
Definition nmrPolynomialBase.h:56
nmrPolynomialTermPowerIndex::VariableIndexType VariableIndexType
Definition nmrPolynomialBase.h:57
InsertStatus
Definition nmrPolynomialBase.h:61
@ INSERT_REPLACE
Definition nmrPolynomialBase.h:61
TermIteratorType FindTerm(const nmrPolynomialTermPowerIndex &target)
Definition nmrPolynomialContainer.h:256
TermContainerType::iterator TermIteratorType
Definition nmrPolynomialContainer.h:74
TermIteratorType EndTermIterator()
Definition nmrPolynomialContainer.h:249
TermContainerType::const_iterator TermConstIteratorType
Definition nmrPolynomialContainer.h:75
Represents the power index of a single term in a multi-variable polynomial.
Definition nmrPolynomialTermPowerIndex.h:90
int GetDegree() const
Definition nmrPolynomialTermPowerIndex.h:121
VariableIndexType GetNumVariables() const
Definition nmrPolynomialTermPowerIndex.h:166
const PowerType * GetPowers() const
Definition nmrPolynomialTermPowerIndex.h:181
virtual void RemoveTerm(TermIteratorType &where)
CoefficientType DereferenceConstIterator(const TermConstIteratorType &it) const
Definition nmrStandardPolynomial.h:202
virtual ~nmrStandardPolynomial()
Definition nmrStandardPolynomial.h:81
virtual CoefficientType GetCoefficient(const nmrPolynomialTermPowerIndex &where) const
Definition nmrStandardPolynomial.h:113
virtual ValueType EvaluateBasis(const nmrPolynomialTermPowerIndex &where, const nmrMultiVariablePowerBasis &variables) const
Definition nmrStandardPolynomial.h:145
nmrStandardPolynomial(VariableIndexType numVariables, PowerType minDegree, PowerType maxDegree)
Definition nmrStandardPolynomial.h:62
virtual void SerializeTermInfo(std::ostream &output, const TermConstIteratorType &termIterator) const
virtual InsertStatus SetCoefficient(const nmrPolynomialTermPowerIndex &where, CoefficientType coefficient)
virtual void AddConstantToCoefficients(CoefficientType coefficients[], CoefficientType shiftAmount) const
CoefficientType & DereferenceIterator(const TermIteratorType &it)
Definition nmrStandardPolynomial.h:193
virtual void Clear()
virtual CoefficientType GetCoefficient(const TermIteratorType &where) const
Definition nmrStandardPolynomial.h:127
CoefficientType DereferenceIterator(const TermIteratorType &it) const
Definition nmrStandardPolynomial.h:199
virtual CoefficientType GetCoefficient(const TermConstIteratorType &where) const
Definition nmrStandardPolynomial.h:122
virtual void DeserializeTermInfo(std::istream &input, TermIteratorType &termIterator)
virtual ValueType EvaluateBasis(const TermConstIteratorType &where, const nmrMultiVariablePowerBasis &variables) const
Definition nmrStandardPolynomial.h:153
virtual ValueType EvaluateBasis(const TermIteratorType &where, const nmrMultiVariablePowerBasis &variables) const
Definition nmrStandardPolynomial.h:159
virtual InsertStatus SetCoefficient(TermIteratorType &where, CoefficientType coefficient)
Definition nmrStandardPolynomial.h:105
virtual void AddConstant(CoefficientType shiftAmount)
nmrDynAllocPolynomialContainer BaseType
Definition nmrStandardPolynomial.h:58
#define CISST_EXPORT
Definition cmnExportMacros.h:50
#define CISST_DEPRECATED
Definition cmnPortability.h:314
Rules of exporting.
#define INCLUDE_DEPRECATED_POLYNOMIAL_CODE
Definition nmrPolynomialBase.h:37