aGrUM  0.14.2
continuousVariable.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
26 #ifndef GUM_CONTINUOUS_VARIABLE_H
27 #define GUM_CONTINUOUS_VARIABLE_H
28 
29 #include <iostream>
30 #include <limits>
31 #include <sstream>
32 #include <string>
33 
34 #include <agrum/agrum.h>
36 
37 namespace gum {
38 
43  template < typename GUM_SCALAR = float >
45  public:
46  // ##########################################################################
48  // ##########################################################################
49 
51 
53 
57  const std::string& aName,
58  const std::string& aDesc,
59  GUM_SCALAR lower_bound = -std::numeric_limits< GUM_SCALAR >::infinity(),
60  GUM_SCALAR upper_bound = std::numeric_limits< GUM_SCALAR >::infinity());
61 
64 
66  template < typename TX_VAL >
68 
71 
73  virtual ~ContinuousVariable();
74 
77  virtual ContinuousVariable< GUM_SCALAR >* clone() const;
78 
80 
81 
82  // ##########################################################################
84  // ##########################################################################
85 
87 
91 
93  template < typename TX_VAL >
96 
100 
102 
105  GUM_SCALAR operator[](const std::string& str) const;
106 
108 
109 
110  // ##########################################################################
112  // ##########################################################################
113 
115 
117  GUM_SCALAR lowerBound() const;
118 
120  virtual double lowerBoundAsDouble() const;
121 
123  GUM_SCALAR upperBound() const;
124 
126  virtual double upperBoundAsDouble() const;
127 
129 
131  void setLowerBound(const GUM_SCALAR& new_bound);
132 
134 
136  virtual void setLowerBoundFromDouble(const double new_bound);
137 
139 
141  void setUpperBound(const GUM_SCALAR& new_bound);
142 
144 
146  virtual void setUpperBoundFromDouble(const double new_bound);
147 
149 
154  virtual std::string label(const GUM_SCALAR& value) const;
155 
157  bool belongs(const GUM_SCALAR& value) const;
158 
160  virtual const std::string domain() const;
161 
163  virtual VarType varType() const;
164 
166  const std::string toString() const;
167 
169  const std::string toStringWithDescription() const;
170 
172 
173 
174  private:
175  // the lower bound.
176  GUM_SCALAR __lower_bound;
177 
178  // the upper bound.
179  GUM_SCALAR __upper_bound;
180 
181  template < typename TX_VAL >
182  friend class ContinuousVariable;
183  };
184 
185 
187  template < typename T_VAL >
188  std::ostream& operator<<(std::ostream&, const ContinuousVariable< T_VAL >&);
189 
190 
191  // specialized operator[] for real numbers
192  template <>
193  float ContinuousVariable< float >::operator[](const std::string& str) const;
194 
195  template <>
196  double ContinuousVariable< double >::operator[](const std::string& str) const;
197 
198 
199 } /* namespace gum */
200 
201 // always include the template implementation
203 
204 #ifndef GUM_NO_INLINE
206 #endif /* GUM_NO_INLINE */
207 
208 #endif /* GUM_CONTINUOUS_VARIABLE_H */
const std::string toStringWithDescription() const
string version of *this using description attribute instead of name.
virtual std::string label(const GUM_SCALAR &value) const
returns a string containing the value of the variable passed in argument
Defines a continuous random variable.
GUM_SCALAR operator[](const std::string &str) const
returns the T_VAL corresponding to a string
virtual double upperBoundAsDouble() const
returns the upper bound of the domain of the variable as a double
virtual double lowerBoundAsDouble() const
returns the lower bound of the domain of the variable as a double
A base class for continuous variables, independent of the GUM_SCALAR type.
const std::string toString() const
string version of *this
ContinuousVariable< GUM_SCALAR > & operator=(const ContinuousVariable< GUM_SCALAR > &from)
copy operator
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual const std::string domain() const
returns the domain of the variable as a string
GUM_SCALAR lowerBound() const
returns the lower bound of the domain of the variable
virtual void setLowerBoundFromDouble(const double new_bound)
updates the lower bound of the domain of the variable
VarType
Definition: variable.h:38
virtual void setUpperBoundFromDouble(const double new_bound)
updates the lower bound of the domain of the variable
bool belongs(const GUM_SCALAR &value) const
Returns true if the param belongs to the domain of the variable.
void setUpperBound(const GUM_SCALAR &new_bound)
updates the lower bound of the domain of the variable
void setLowerBound(const GUM_SCALAR &new_bound)
updates the lower bound of the domain of the variable
virtual ContinuousVariable< GUM_SCALAR > * clone() const
Copy Factory.
Header of IContinuousVariable.
virtual VarType varType() const
returns the type of the variable
GUM_SCALAR upperBound() const
returns the upper bound of the domain of the variable
ContinuousVariable.
virtual ~ContinuousVariable()
destructor
The databases&#39; cell translators for continuous variables.