template <> struct name<type> : binary_function<type, type, type> \
{ \
__device__ __forceinline__ type operator()(type lhs, type rhs) const {return op(lhs, rhs);} \
- __device__ __forceinline__ name(const name& other):binary_function<type, type, type>(){}\
- __device__ __forceinline__ name():binary_function<type, type, type>(){}\
+ __device__ __forceinline__ name() {}\
+ __device__ __forceinline__ name(const name&) {}\
};
template <typename T> struct maximum : binary_function<T, T, T>
{
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType lhs, typename TypeTraits<T>::ParameterType rhs) const
{
- return lhs < rhs ? rhs : lhs;
+ return max(lhs, rhs);
}
- __device__ __forceinline__ maximum(const maximum& other):binary_function<T, T, T>(){}
- __device__ __forceinline__ maximum():binary_function<T, T, T>(){}
+ __device__ __forceinline__ maximum() {}
+ __device__ __forceinline__ maximum(const maximum&) {}
};
OPENCV_GPU_IMPLEMENT_MINMAX(maximum, uchar, ::max)
{
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType lhs, typename TypeTraits<T>::ParameterType rhs) const
{
- return lhs < rhs ? lhs : rhs;
+ return min(lhs, rhs);
}
- __device__ __forceinline__ minimum(const minimum& other):binary_function<T, T, T>(){}
- __device__ __forceinline__ minimum():binary_function<T, T, T>(){}
+ __device__ __forceinline__ minimum() {}
+ __device__ __forceinline__ minimum(const minimum&) {}
};
OPENCV_GPU_IMPLEMENT_MINMAX(minimum, uchar, ::min)
// Math functions
///bound=========================================
+
+ template <typename T> struct abs_func : unary_function<T, T>
+ {
+ __device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType x) const
+ {
+ return abs(x);
+ }
+ };
+ template <> struct abs_func<unsigned char> : unary_function<unsigned char, unsigned char>
+ {
+ __device__ __forceinline__ unsigned char operator ()(unsigned char x) const
+ {
+ return x;
+ }
+ };
+ template <> struct abs_func<signed char> : unary_function<signed char, signed char>
+ {
+ __device__ __forceinline__ signed char operator ()(signed char x) const
+ {
+ return ::abs(x);
+ }
+ };
+ template <> struct abs_func<char> : unary_function<char, char>
+ {
+ __device__ __forceinline__ char operator ()(char x) const
+ {
+ return ::abs(x);
+ }
+ };
+ template <> struct abs_func<unsigned short> : unary_function<unsigned short, unsigned short>
+ {
+ __device__ __forceinline__ unsigned short operator ()(unsigned short x) const
+ {
+ return x;
+ }
+ };
+ template <> struct abs_func<short> : unary_function<short, short>
+ {
+ __device__ __forceinline__ short operator ()(short x) const
+ {
+ return ::abs(x);
+ }
+ };
+ template <> struct abs_func<unsigned int> : unary_function<unsigned int, unsigned int>
+ {
+ __device__ __forceinline__ unsigned int operator ()(unsigned int x) const
+ {
+ return x;
+ }
+ };
+ template <> struct abs_func<int> : unary_function<int, int>
+ {
+ __device__ __forceinline__ int operator ()(int x) const
+ {
+ return ::abs(x);
+ }
+ };
+ template <> struct abs_func<float> : unary_function<float, float>
+ {
+ __device__ __forceinline__ float operator ()(float x) const
+ {
+ return ::fabsf(x);
+ }
+ };
+ template <> struct abs_func<double> : unary_function<double, double>
+ {
+ __device__ __forceinline__ double operator ()(double x) const
+ {
+ return ::fabs(x);
+ }
+ };
+
#define OPENCV_GPU_IMPLEMENT_UN_FUNCTOR(name, func) \
template <typename T> struct name ## _func : unary_function<T, float> \
{ \
} \
};
- OPENCV_GPU_IMPLEMENT_UN_FUNCTOR(fabs, ::fabs)
OPENCV_GPU_IMPLEMENT_UN_FUNCTOR(sqrt, ::sqrt)
OPENCV_GPU_IMPLEMENT_UN_FUNCTOR(exp, ::exp)
OPENCV_GPU_IMPLEMENT_UN_FUNCTOR(exp2, ::exp2)
OPENCV_GPU_IMPLEMENT_VEC_UNOP (type, operator ! , logical_not) \
OPENCV_GPU_IMPLEMENT_VEC_BINOP(type, max, maximum) \
OPENCV_GPU_IMPLEMENT_VEC_BINOP(type, min, minimum) \
- OPENCV_GPU_IMPLEMENT_VEC_UNOP(type, fabs, fabs_func) \
+ OPENCV_GPU_IMPLEMENT_VEC_UNOP(type, abs, abs_func) \
OPENCV_GPU_IMPLEMENT_VEC_UNOP(type, sqrt, sqrt_func) \
OPENCV_GPU_IMPLEMENT_VEC_UNOP(type, exp, exp_func) \
OPENCV_GPU_IMPLEMENT_VEC_UNOP(type, exp2, exp2_func) \
#undef OPENCV_GPU_IMPLEMENT_VEC_INT_OP
}}} // namespace cv { namespace gpu { namespace device
-#endif // __OPENCV_GPU_VECMATH_HPP__
\ No newline at end of file
+#endif // __OPENCV_GPU_VECMATH_HPP__