aGrUM  0.14.2
functors.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  ********************************************************************************/
33 // =========================================================================
34 #ifndef GUM_FUNCTORS_H
35 #define GUM_FUNCTORS_H
36 // =========================================================================
37 #include <cstdlib>
38 // =========================================================================
39 #include <agrum/core/argMaxSet.h>
40 // =========================================================================
41 
42 
43 namespace gum {
44 
52  template < class GUM_SCALAR >
53  struct Maximizes {
54  // ###########################################################################
56  // ###########################################################################
58 
59  GUM_SCALAR operator()(const GUM_SCALAR& x, const GUM_SCALAR& y) const {
60  return x >= y ? x : y;
61  }
62 
64 
65  typedef GUM_SCALAR first_argument_type;
66  typedef GUM_SCALAR second_argument_type;
67  typedef GUM_SCALAR result_type;
68  };
69 
77  template < class GUM_SCALAR >
78  struct Minimizes {
79  // ###########################################################################
81  // ###########################################################################
83 
84  GUM_SCALAR operator()(const GUM_SCALAR& x, const GUM_SCALAR& y) const {
85  return x <= y ? x : y;
86  }
87 
89 
90  typedef GUM_SCALAR first_argument_type;
91  typedef GUM_SCALAR second_argument_type;
92  typedef GUM_SCALAR result_type;
93  };
94 
107  template < class GUM_SCALAR >
109  // ###########################################################################
111  // ###########################################################################
113 
114  GUM_SCALAR operator()(const GUM_SCALAR& x, const GUM_SCALAR& y) const {
115  return x.first >= y.first ? x : y;
116  }
117 
119 
120  typedef GUM_SCALAR first_argument_type;
121  typedef GUM_SCALAR second_argument_type;
122  typedef GUM_SCALAR result_type;
123  };
124 } // namespace gum
125 
126 #endif // GUM_FUNCTORS_H
GUM_SCALAR result_type
Definition: functors.h:122
GUM_SCALAR first_argument_type
Definition: functors.h:120
GUM_SCALAR second_argument_type
Definition: functors.h:121
GUM_SCALAR operator()(const GUM_SCALAR &x, const GUM_SCALAR &y) const
Definition: functors.h:114
GUM_SCALAR operator()(const GUM_SCALAR &x, const GUM_SCALAR &y) const
Definition: functors.h:84
Arg Max function object class.
Definition: functors.h:108
Maximization function object classReturns the maximum of its two arguments.
Definition: functors.h:53
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
GUM_SCALAR second_argument_type
Definition: functors.h:91
GUM_SCALAR first_argument_type
Definition: functors.h:65
Minimization function object classReturns the minimum of its two arguments.
Definition: functors.h:78
GUM_SCALAR first_argument_type
Definition: functors.h:90
GUM_SCALAR operator()(const GUM_SCALAR &x, const GUM_SCALAR &y) const
Definition: functors.h:59
This files contains several function objects that are not (yet) defined in the STL.
GUM_SCALAR second_argument_type
Definition: functors.h:66
GUM_SCALAR result_type
Definition: functors.h:92
GUM_SCALAR result_type
Definition: functors.h:67