aGrUM  0.16.0
continuousVariable.h
Go to the documentation of this file.
1 
29 #ifndef GUM_CONTINUOUS_VARIABLE_H
30 #define GUM_CONTINUOUS_VARIABLE_H
31 
32 #include <iostream>
33 #include <limits>
34 #include <sstream>
35 #include <string>
36 
37 #include <agrum/agrum.h>
39 
40 namespace gum {
41 
46  template < typename GUM_SCALAR = float >
48  public:
49  // ##########################################################################
51  // ##########################################################################
52 
54 
56 
60  const std::string& aName,
61  const std::string& aDesc,
62  GUM_SCALAR lower_bound = -std::numeric_limits< GUM_SCALAR >::infinity(),
63  GUM_SCALAR upper_bound = std::numeric_limits< GUM_SCALAR >::infinity());
64 
67 
69  template < typename TX_VAL >
71 
74 
76  virtual ~ContinuousVariable();
77 
80  virtual ContinuousVariable< GUM_SCALAR >* clone() const;
81 
83 
84 
85  // ##########################################################################
87  // ##########################################################################
88 
90 
94 
96  template < typename TX_VAL >
99 
103 
105 
108  GUM_SCALAR operator[](const std::string& str) const;
109 
111 
112 
113  // ##########################################################################
115  // ##########################################################################
116 
118 
120  GUM_SCALAR lowerBound() const;
121 
123  virtual double lowerBoundAsDouble() const;
124 
126  GUM_SCALAR upperBound() const;
127 
129  virtual double upperBoundAsDouble() const;
130 
132 
134  void setLowerBound(const GUM_SCALAR& new_bound);
135 
137 
139  virtual void setLowerBoundFromDouble(const double new_bound);
140 
142 
144  void setUpperBound(const GUM_SCALAR& new_bound);
145 
147 
149  virtual void setUpperBoundFromDouble(const double new_bound);
150 
152 
157  virtual std::string label(const GUM_SCALAR& value) const;
158 
160  bool belongs(const GUM_SCALAR& value) const;
161 
163  virtual const std::string domain() const;
164 
166  virtual VarType varType() const;
167 
169  const std::string toString() const;
170 
172  const std::string toStringWithDescription() const;
173 
175 
176 
177  private:
178  // the lower bound.
179  GUM_SCALAR __lower_bound;
180 
181  // the upper bound.
182  GUM_SCALAR __upper_bound;
183 
184  template < typename TX_VAL >
185  friend class ContinuousVariable;
186  };
187 
188 
190  template < typename T_VAL >
191  std::ostream& operator<<(std::ostream&, const ContinuousVariable< T_VAL >&);
192 
193 
194  // specialized operator[] for real numbers
195  template <>
196  float ContinuousVariable< float >::operator[](const std::string& str) const;
197 
198  template <>
199  double ContinuousVariable< double >::operator[](const std::string& str) const;
200 
201 
202 } /* namespace gum */
203 
204 // always include the template implementation
206 
207 #ifndef GUM_NO_INLINE
209 #endif /* GUM_NO_INLINE */
210 
211 #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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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:41
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual VarType varType() const
returns the type of the variable
GUM_SCALAR upperBound() const
returns the upper bound of the domain of the variable
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ~ContinuousVariable()
destructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.