2 #ifndef OPENGM_FUNCTORS_HXX
3 #define OPENGM_FUNCTORS_HXX
12 template<
class ACC,
class VALUE_TYPE>
13 class AccumulationFunctor{
15 AccumulationFunctor(
const VALUE_TYPE v)
20 :accValue_(ACC::template neutral<VALUE_TYPE>()) {
24 void operator()(
const VALUE_TYPE v) {
46 MinMaxFunctor(T min,T max)
60 void operator()(
const ValueType v) {
91 PowFunctor(
const PowFunctor& other)
97 const T operator()(T_In value) {
98 return std::pow(value, w_);
104 template<
class T_ReturnType,
class T_Functor>
105 class SwapArgumemtFunctor {
109 SwapArgumemtFunctor(
const SwapArgumemtFunctor& other)
110 : functor_(other.functor_) {
114 SwapArgumemtFunctor(T_Functor functor)
115 : functor_(functor) {
120 template<
class T_A,
class T_B>
121 T_ReturnType operator()(T_A a, T_B b) {
122 return functor_(b, a);
129 template<
class T_Scalar,
class T_Functor,
bool ScalarLeft>
130 class BinaryToUnaryFunctor;
133 template<
class T_Scalar,
class T_Functor>
134 class BinaryToUnaryFunctor<T_Scalar, T_Functor, true> {
136 BinaryToUnaryFunctor(
const BinaryToUnaryFunctor& other)
137 : functor_(other.functor_),
138 scalar_(other.scalar_) {
140 BinaryToUnaryFunctor(
const T_Scalar& scalar, T_Functor& functor)
146 T_Scalar operator()(
const TIN in) {
147 return functor_(scalar_, in);
156 template<
class T_Scalar,
class T_Functor>
157 class BinaryToUnaryFunctor<T_Scalar, T_Functor, false> {
159 BinaryToUnaryFunctor(
const BinaryToUnaryFunctor& other)
160 : functor_(other.functor_),
161 scalar_(other.scalar_) {
163 BinaryToUnaryFunctor(
const T_Scalar& scalar, T_Functor& functor)
168 T_Scalar operator()(
const TIN in) {
169 return functor_(in, scalar_);
178 template<
class OUT_ITERATOR>
181 CopyFunctor(OUT_ITERATOR iterator):outIterator_(iterator){}
183 void operator()(
const T & value){
184 (*outIterator_)=value;
188 OUT_ITERATOR outIterator_;
196 #endif // #ifndef OPENGM_FUNCTORS_HXX