aGrUM  0.16.0
amplitude_tpl.h
Go to the documentation of this file.
1 
30 #include <sstream>
31 #include <vector>
32 
33 // to ease parser in IDEs
36 
37 namespace gum {
38 
39  namespace aggregator {
40  template < typename GUM_SCALAR >
42  MultiDimAggregator< GUM_SCALAR >() {
43  GUM_CONSTRUCTOR(Amplitude);
44  }
45 
46  template < typename GUM_SCALAR >
47  INLINE
49  MultiDimAggregator< GUM_SCALAR >(from) {
50  GUM_CONS_CPY(Amplitude);
51  }
52 
53  template < typename GUM_SCALAR >
55  GUM_DESTRUCTOR(Amplitude);
56  }
57 
58  template < typename GUM_SCALAR >
59  INLINE std::string Amplitude< GUM_SCALAR >::aggregatorName() const {
60  std::stringstream ss;
61  ss << "amplitude";
62  return ss.str();
63  }
64 
65  template < typename GUM_SCALAR >
68  return new Amplitude< GUM_SCALAR >();
69  }
70 
71  template < typename GUM_SCALAR >
73  // we assume that every (parent) variable has the same domainSize
74  if (i.nbrDim() < 2) return 0;
75 
76  Idx min = i.val(1);
77  Idx max = i.val(1);
78 
79  for (Idx j = 2; j < this->nbrDim(); j++) {
80  Idx m = i.val(j);
81  if (m < min) min = m;
82  if (m > max) max = m;
83  }
84  return max - min; // multiDimAggregator::get will truncate if needed.
85  }
86 
87  template < typename GUM_SCALAR >
89  Idx i1,
90  Idx i2,
91  bool& stop_iteration) const {
92  return 0;
93  }
94 
95  } // namespace aggregator
96 } // namespace gum
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
virtual Idx _fold(const DiscreteVariable &v, Idx i1, Idx i2, bool &stop_iteration) const
_fold is applied on value i1 for variable v. the actual result for precedent applications is i2...
Definition: amplitude_tpl.h:88
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Abstract base class for all multi dimensionnal containers.
<agrum/multidim/aggregators/multiDimAggregator.h>
Idx val(Idx i) const
Returns the current value of the variable at position i.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const
This method creates a clone of this object, withouth its content (including variable), you must use this method if you want to ensure that the generated object has the same type than the object containing the called newFactory() For example :
Definition: amplitude_tpl.h:67
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual Idx nbrDim() const override
Returns the number of vars in the multidimensional container.
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
Size Idx
Type for indexes.
Definition: types.h:53
amplitude aggregator
Definition: amplitude.h:55
virtual Idx _buildValue(const gum::Instantiation &i) const
by default, _buildValue uses a "fold" scheme and the user has to implement _neutralElt and _fold but ...
Definition: amplitude_tpl.h:72
virtual std::string aggregatorName() const
Definition: amplitude_tpl.h:59