34 #ifndef _OPERATIONS_H_ 35 #define _OPERATIONS_H_ 41 #include "psort/MersenneTwister.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>
81 struct myidentity :
public std::unary_function<T, T>
92 struct totality :
public std::unary_function<T, bool>
103 struct safemultinv :
public std::unary_function<T, T>
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>
123 struct bintotality :
public std::binary_function<T1, T2, bool>
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>
185 struct RandReduce :
public std::binary_function<T, T, T>
190 return (M.rand() < 0.5)? x : y;
233 struct bitwise_and :
public std::binary_function<T, T, T>
251 struct bitwise_or :
public std::binary_function<T, T, T>
268 struct logical_xor :
public std::binary_function<T, T, T>
273 return (x || y) && !(x && y);
286 struct bitwise_xor :
public std::binary_function<T, T, T>
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.
Returns a special value (passed to the constructor of the functor) when both operants disagree...
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
const T operator()(const T &x, const T &y)
const T operator()(const T &x) const
double operator()(double x, double y) const
With 50/50 chances, return a one of the operants.
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
bool operator()(const T &x) const
T operator()(const T &x, const T &y) const
T operator()(const T &x, const T &y) const