aGrUM  0.15.0
functors.h
Go to the documentation of this file.
1 
36 // =========================================================================
37 #ifndef GUM_FUNCTORS_H
38 #define GUM_FUNCTORS_H
39 // =========================================================================
40 #include <cstdlib>
41 // =========================================================================
42 #include <agrum/core/argMaxSet.h>
43 // =========================================================================
44 
45 
46 namespace gum {
47 
55  template < class GUM_SCALAR >
56  struct Maximizes {
57  // ###########################################################################
59  // ###########################################################################
61 
62  GUM_SCALAR operator()(const GUM_SCALAR& x, const GUM_SCALAR& y) const {
63  return x >= y ? x : y;
64  }
65 
67 
68  typedef GUM_SCALAR first_argument_type;
69  typedef GUM_SCALAR second_argument_type;
70  typedef GUM_SCALAR result_type;
71  };
72 
80  template < class GUM_SCALAR >
81  struct Minimizes {
82  // ###########################################################################
84  // ###########################################################################
86 
87  GUM_SCALAR operator()(const GUM_SCALAR& x, const GUM_SCALAR& y) const {
88  return x <= y ? x : y;
89  }
90 
92 
93  typedef GUM_SCALAR first_argument_type;
94  typedef GUM_SCALAR second_argument_type;
95  typedef GUM_SCALAR result_type;
96  };
97 
110  template < class GUM_SCALAR >
112  // ###########################################################################
114  // ###########################################################################
116 
117  GUM_SCALAR operator()(const GUM_SCALAR& x, const GUM_SCALAR& y) const {
118  return x.first >= y.first ? x : y;
119  }
120 
122 
123  typedef GUM_SCALAR first_argument_type;
124  typedef GUM_SCALAR second_argument_type;
125  typedef GUM_SCALAR result_type;
126  };
127 } // namespace gum
128 
129 #endif // GUM_FUNCTORS_H
GUM_SCALAR result_type
Definition: functors.h:125
GUM_SCALAR first_argument_type
Definition: functors.h:123
GUM_SCALAR second_argument_type
Definition: functors.h:124
GUM_SCALAR operator()(const GUM_SCALAR &x, const GUM_SCALAR &y) const
Definition: functors.h:117
GUM_SCALAR operator()(const GUM_SCALAR &x, const GUM_SCALAR &y) const
Definition: functors.h:87
Arg Max function object class.
Definition: functors.h:111
Maximization function object classReturns the maximum of its two arguments.
Definition: functors.h:56
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
GUM_SCALAR second_argument_type
Definition: functors.h:94
GUM_SCALAR first_argument_type
Definition: functors.h:68
Minimization function object classReturns the minimum of its two arguments.
Definition: functors.h:81
GUM_SCALAR first_argument_type
Definition: functors.h:93
GUM_SCALAR operator()(const GUM_SCALAR &x, const GUM_SCALAR &y) const
Definition: functors.h:62
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
GUM_SCALAR second_argument_type
Definition: functors.h:69
GUM_SCALAR result_type
Definition: functors.h:95
GUM_SCALAR result_type
Definition: functors.h:70