cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nmrSingleVariablePowerBasis.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-08-20
8 
9  (C) Copyright 2003-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 _nmrSingleVariablePowerBasis_h
23 #define _nmrSingleVariablePowerBasis_h
24 
25 
26 #include <vector>
27 #include <algorithm>
28 #include <assert.h>
29 
33 
34 #ifdef CISST_COMPILER_IS_MSVC
35 #pragma warning(push)
36 #pragma warning(disable:4996)
37 #endif // ifdef CISST_COMPILER_IS_MSVC
38 
43 {
44 public:
45  typedef double VariableType;
47 
48 private:
49  typedef std::vector<VariableType> PowersContainerType;
50  PowersContainerType PowersContainer;
51 
52 public:
54  : PowersContainer( std::max<PowerType>(degree+1,2), 0)
55  {
56  PowersContainer[0] = 1;
57  }
58 
62  void Initialize(PowerType degree)
63  {
64  PowersContainer.resize(degree+1);
65  PowersContainer.assign(degree+1, 0);
66  PowersContainer[0] = 1;
67  }
68 
71  {
72  return PowersContainer.size() - 1;
73  }
74 
77  {
78  return PowersContainer[1];
79  }
80 
83  {
84  assert(power <= GetDegree());
85  return PowersContainer[power];
86  }
87 
90  {
91  return PowersContainer[power];
92  }
93 
95  void SetVariable(VariableType variable);
96 };
97 #ifdef CISST_COMPILER_IS_MSVC
98 #pragma warning(pop)
99 #endif // ifdef CISST_COMPILER_IS_MSVC
100 
101 #endif
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
nmrPolynomialTermPowerIndex::PowerType PowerType
Definition: nmrSingleVariablePowerBasis.h:46
#define CISST_DEPRECATED
Definition: cmnPortability.h:310
VariableType operator[](PowerType power) const
Definition: nmrSingleVariablePowerBasis.h:89
Portability across compilers and operating systems tools.
PowerType GetDegree() const
Definition: nmrSingleVariablePowerBasis.h:70
Definition: nmrSingleVariablePowerBasis.h:42
VariableType GetVariable() const
Definition: nmrSingleVariablePowerBasis.h:76
double VariableType
Definition: nmrSingleVariablePowerBasis.h:45
void Initialize(PowerType degree)
Definition: nmrSingleVariablePowerBasis.h:62
int PowerType
Definition: nmrPolynomialTermPowerIndex.h:98
nmrSingleVariablePowerBasis(PowerType degree)
Definition: nmrSingleVariablePowerBasis.h:53
Declare class nmrPolynomialTermPowerIndex to represent the power index of a single term in a multi-va...
VariableType GetVariablePower(PowerType power) const
Definition: nmrSingleVariablePowerBasis.h:82
Rules of exporting.