34 #ifndef _OPERATIONS_H_ 35 #define _OPERATIONS_H_ 45 template<
typename T1,
typename T2>
48 bool operator()(std::pair<T1,T2> & lhs, std::pair<T1,T2> & rhs){
49 return lhs.first == rhs.first;
56 struct myset:
public std::unary_function<T, T>
58 myset(T myvalue): value(myvalue) {};
69 struct identity :
public std::unary_function<T, T>
92 struct totality :
public std::unary_function<T, bool>
107 T inf = std::numeric_limits<T>::max();
108 return (x == 0) ? inf:(1/x);
114 struct sel2nd:
public std::binary_function<T, T, T>
122 template<
typename T1,
typename T2>
140 struct exponentiate :
public std::binary_function<double, double, double>
142 double operator()(
double x,
double y)
const {
return std::pow(x, y); }
154 struct maximum :
public std::binary_function<T, T, T>
172 struct minimum :
public std::binary_function<T, T, T>
190 return (M.rand() < 0.5)? x : y;
273 return (x || y) && !(x && y);
Returns a special value (passed to the constructor of the functor) when both operants disagree...
Compute the minimum of two values.
bool operator()(const T1 &x, const T2 &y) const
Compute the bitwise AND of two integral values.
const T operator()(const T &x) const
Compute the maximum of two values.
Compute the bitwise OR of two integral values.
const T operator()(const T &x, const T &y) const
const T operator()(const T &x, const T &y)
T operator()(const T &x, const T &y) const
With 50/50 chances, return a one of the operants.
const T operator()(const T &x) const
double operator()(double x, double y) const
Compute the bitwise exclusive OR of two integral values.
const T & operator()(const T &x) const
Compute the logical exclusive OR of two integral values.
const T operator()(const T &x, const T &y) const
T operator()(const T &x, const T &y) const
const T operator()(const T &x) const
bool operator()(std::pair< T1, T2 > &lhs, std::pair< T1, T2 > &rhs)
const T & operator()(const T &x, const T &y) const
const T operator()(const T &x, const T &y)
bool operator()(const T &x) const
T operator()(const T &x, const T &y) const
T operator()(const T &x, const T &y) const