43 #ifndef OPENCV_CUDA_FUNCTIONAL_HPP
44 #define OPENCV_CUDA_FUNCTIONAL_HPP
47 #include "saturate_cast.hpp"
48 #include "vec_traits.hpp"
49 #include "type_traits.hpp"
57 namespace cv {
namespace cuda {
namespace device
60 template<
typename Argument,
typename Result>
struct unary_function
62 typedef Argument argument_type;
63 typedef Result result_type;
65 template<
typename Argument1,
typename Argument2,
typename Result>
struct binary_function
67 typedef Argument1 first_argument_type;
68 typedef Argument2 second_argument_type;
69 typedef Result result_type;
73 template <
typename T>
struct plus : binary_function<T, T, T>
75 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
76 typename TypeTraits<T>::ParameterType b)
const
80 __host__ __device__ __forceinline__ plus() {}
81 __host__ __device__ __forceinline__ plus(
const plus&) {}
84 template <
typename T>
struct minus : binary_function<T, T, T>
86 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
87 typename TypeTraits<T>::ParameterType b)
const
91 __host__ __device__ __forceinline__ minus() {}
92 __host__ __device__ __forceinline__ minus(
const minus&) {}
95 template <
typename T>
struct multiplies : binary_function<T, T, T>
97 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
98 typename TypeTraits<T>::ParameterType b)
const
102 __host__ __device__ __forceinline__ multiplies() {}
103 __host__ __device__ __forceinline__ multiplies(
const multiplies&) {}
106 template <
typename T>
struct divides : binary_function<T, T, T>
108 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
109 typename TypeTraits<T>::ParameterType b)
const
113 __host__ __device__ __forceinline__ divides() {}
114 __host__ __device__ __forceinline__ divides(
const divides&) {}
117 template <
typename T>
struct modulus : binary_function<T, T, T>
119 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
120 typename TypeTraits<T>::ParameterType b)
const
124 __host__ __device__ __forceinline__ modulus() {}
125 __host__ __device__ __forceinline__ modulus(
const modulus&) {}
128 template <
typename T>
struct negate : unary_function<T, T>
130 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a)
const
134 __host__ __device__ __forceinline__ negate() {}
135 __host__ __device__ __forceinline__ negate(
const negate&) {}
139 template <
typename T>
struct equal_to : binary_function<T, T, bool>
141 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
142 typename TypeTraits<T>::ParameterType b)
const
146 __host__ __device__ __forceinline__ equal_to() {}
147 __host__ __device__ __forceinline__ equal_to(
const equal_to&) {}
150 template <
typename T>
struct not_equal_to : binary_function<T, T, bool>
152 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
153 typename TypeTraits<T>::ParameterType b)
const
157 __host__ __device__ __forceinline__ not_equal_to() {}
158 __host__ __device__ __forceinline__ not_equal_to(
const not_equal_to&) {}
161 template <
typename T>
struct greater : binary_function<T, T, bool>
163 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
164 typename TypeTraits<T>::ParameterType b)
const
168 __host__ __device__ __forceinline__ greater() {}
169 __host__ __device__ __forceinline__ greater(
const greater&) {}
172 template <
typename T>
struct less : binary_function<T, T, bool>
174 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
175 typename TypeTraits<T>::ParameterType b)
const
179 __host__ __device__ __forceinline__ less() {}
180 __host__ __device__ __forceinline__ less(
const less&) {}
183 template <
typename T>
struct greater_equal : binary_function<T, T, bool>
185 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
186 typename TypeTraits<T>::ParameterType b)
const
190 __host__ __device__ __forceinline__ greater_equal() {}
191 __host__ __device__ __forceinline__ greater_equal(
const greater_equal&) {}
194 template <
typename T>
struct less_equal : binary_function<T, T, bool>
196 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
197 typename TypeTraits<T>::ParameterType b)
const
201 __host__ __device__ __forceinline__ less_equal() {}
202 __host__ __device__ __forceinline__ less_equal(
const less_equal&) {}
206 template <
typename T>
struct logical_and : binary_function<T, T, bool>
208 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
209 typename TypeTraits<T>::ParameterType b)
const
213 __host__ __device__ __forceinline__ logical_and() {}
214 __host__ __device__ __forceinline__ logical_and(
const logical_and&) {}
217 template <
typename T>
struct logical_or : binary_function<T, T, bool>
219 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a,
220 typename TypeTraits<T>::ParameterType b)
const
224 __host__ __device__ __forceinline__ logical_or() {}
225 __host__ __device__ __forceinline__ logical_or(
const logical_or&) {}
228 template <
typename T>
struct logical_not : unary_function<T, bool>
230 __device__ __forceinline__
bool operator ()(
typename TypeTraits<T>::ParameterType a)
const
234 __host__ __device__ __forceinline__ logical_not() {}
235 __host__ __device__ __forceinline__ logical_not(
const logical_not&) {}
239 template <
typename T>
struct bit_and : binary_function<T, T, T>
241 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
242 typename TypeTraits<T>::ParameterType b)
const
246 __host__ __device__ __forceinline__ bit_and() {}
247 __host__ __device__ __forceinline__ bit_and(
const bit_and&) {}
250 template <
typename T>
struct bit_or : binary_function<T, T, T>
252 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
253 typename TypeTraits<T>::ParameterType b)
const
257 __host__ __device__ __forceinline__ bit_or() {}
258 __host__ __device__ __forceinline__ bit_or(
const bit_or&) {}
261 template <
typename T>
struct bit_xor : binary_function<T, T, T>
263 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType a,
264 typename TypeTraits<T>::ParameterType b)
const
268 __host__ __device__ __forceinline__ bit_xor() {}
269 __host__ __device__ __forceinline__ bit_xor(
const bit_xor&) {}
272 template <
typename T>
struct bit_not : unary_function<T, T>
274 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType v)
const
278 __host__ __device__ __forceinline__ bit_not() {}
279 __host__ __device__ __forceinline__ bit_not(
const bit_not&) {}
283 template <
typename T>
struct identity : unary_function<T, T>
285 __device__ __forceinline__
typename TypeTraits<T>::ParameterType operator()(
typename TypeTraits<T>::ParameterType
x)
const
289 __host__ __device__ __forceinline__ identity() {}
290 __host__ __device__ __forceinline__ identity(
const identity&) {}
293 template <
typename T1,
typename T2>
struct project1st : binary_function<T1, T2, T1>
295 __device__ __forceinline__
typename TypeTraits<T1>::ParameterType operator()(
typename TypeTraits<T1>::ParameterType lhs,
typename TypeTraits<T2>::ParameterType rhs)
const
299 __host__ __device__ __forceinline__ project1st() {}
300 __host__ __device__ __forceinline__ project1st(
const project1st&) {}
303 template <
typename T1,
typename T2>
struct project2nd : binary_function<T1, T2, T2>
305 __device__ __forceinline__
typename TypeTraits<T2>::ParameterType operator()(
typename TypeTraits<T1>::ParameterType lhs,
typename TypeTraits<T2>::ParameterType rhs)
const
309 __host__ __device__ __forceinline__ project2nd() {}
310 __host__ __device__ __forceinline__ project2nd(
const project2nd&) {}
315 #define OPENCV_CUDA_IMPLEMENT_MINMAX(name, type, op) \
316 template <> struct name<type> : binary_function<type, type, type> \
318 __device__ __forceinline__ type operator()(type lhs, type rhs) const {return op(lhs, rhs);} \
319 __host__ __device__ __forceinline__ name() {}\
320 __host__ __device__ __forceinline__ name(const name&) {}\
323 template <
typename T>
struct maximum : binary_function<T, T, T>
325 __device__ __forceinline__
T operator()(
typename TypeTraits<T>::ParameterType lhs,
typename TypeTraits<T>::ParameterType rhs)
const
327 return max(lhs, rhs);
329 __host__ __device__ __forceinline__ maximum() {}
330 __host__ __device__ __forceinline__ maximum(
const maximum&) {}
333 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
uchar, ::
max)
334 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
schar, ::
max)
335 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
char, ::
max)
336 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
ushort, ::
max)
337 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
short, ::
max)
338 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
int, ::
max)
339 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
uint, ::
max)
340 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
float, ::fmax)
341 OPENCV_CUDA_IMPLEMENT_MINMAX(maximum,
double, ::fmax)
343 template <
typename T>
struct minimum : binary_function<T, T, T>
345 __device__ __forceinline__
T operator()(
typename TypeTraits<T>::ParameterType lhs,
typename TypeTraits<T>::ParameterType rhs)
const
347 return min(lhs, rhs);
349 __host__ __device__ __forceinline__ minimum() {}
350 __host__ __device__ __forceinline__ minimum(
const minimum&) {}
353 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
uchar, ::
min)
354 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
schar, ::
min)
355 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
char, ::
min)
356 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
ushort, ::
min)
357 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
short, ::
min)
358 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
int, ::
min)
359 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
uint, ::
min)
360 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
float, ::fmin)
361 OPENCV_CUDA_IMPLEMENT_MINMAX(minimum,
double, ::fmin)
363 #undef OPENCV_CUDA_IMPLEMENT_MINMAX
367 template <
typename T>
struct abs_func : unary_function<T, T>
369 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType
x)
const
374 __host__ __device__ __forceinline__ abs_func() {}
375 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
377 template <>
struct abs_func<unsigned char> : unary_function<unsigned char, unsigned char>
379 __device__ __forceinline__
unsigned char operator ()(
unsigned char x)
const
384 __host__ __device__ __forceinline__ abs_func() {}
385 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
387 template <>
struct abs_func<signed char> : unary_function<signed char, signed char>
389 __device__ __forceinline__
signed char operator ()(
signed char x)
const
394 __host__ __device__ __forceinline__ abs_func() {}
395 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
397 template <>
struct abs_func<char> : unary_function<char, char>
399 __device__ __forceinline__
char operator ()(
char x)
const
404 __host__ __device__ __forceinline__ abs_func() {}
405 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
407 template <>
struct abs_func<unsigned short> : unary_function<unsigned short, unsigned short>
409 __device__ __forceinline__
unsigned short operator ()(
unsigned short x)
const
414 __host__ __device__ __forceinline__ abs_func() {}
415 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
417 template <>
struct abs_func<short> : unary_function<short, short>
419 __device__ __forceinline__
short operator ()(
short x)
const
424 __host__ __device__ __forceinline__ abs_func() {}
425 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
427 template <>
struct abs_func<unsigned int> : unary_function<unsigned int, unsigned int>
429 __device__ __forceinline__
unsigned int operator ()(
unsigned int x)
const
434 __host__ __device__ __forceinline__ abs_func() {}
435 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
437 template <>
struct abs_func<int> : unary_function<int, int>
439 __device__ __forceinline__
int operator ()(
int x)
const
444 __host__ __device__ __forceinline__ abs_func() {}
445 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
447 template <>
struct abs_func<float> : unary_function<float, float>
449 __device__ __forceinline__
float operator ()(
float x)
const
454 __host__ __device__ __forceinline__ abs_func() {}
455 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
457 template <>
struct abs_func<double> : unary_function<double, double>
459 __device__ __forceinline__
double operator ()(
double x)
const
464 __host__ __device__ __forceinline__ abs_func() {}
465 __host__ __device__ __forceinline__ abs_func(
const abs_func&) {}
468 #define OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(name, func) \
469 template <typename T> struct name ## _func : unary_function<T, float> \
471 __device__ __forceinline__ float operator ()(typename TypeTraits<T>::ParameterType v) const \
473 return func ## f(v); \
475 __host__ __device__ __forceinline__ name ## _func() {} \
476 __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
478 template <> struct name ## _func<double> : unary_function<double, double> \
480 __device__ __forceinline__ double operator ()(double v) const \
484 __host__ __device__ __forceinline__ name ## _func() {} \
485 __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
488 #define OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(name, func) \
489 template <typename T> struct name ## _func : binary_function<T, T, float> \
491 __device__ __forceinline__ float operator ()(typename TypeTraits<T>::ParameterType v1, typename TypeTraits<T>::ParameterType v2) const \
493 return func ## f(v1, v2); \
495 __host__ __device__ __forceinline__ name ## _func() {} \
496 __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
498 template <> struct name ## _func<double> : binary_function<double, double, double> \
500 __device__ __forceinline__ double operator ()(double v1, double v2) const \
502 return func(v1, v2); \
504 __host__ __device__ __forceinline__ name ## _func() {} \
505 __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
508 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
sqrt, ::
sqrt)
509 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
exp, ::
exp)
510 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp2, ::exp2)
511 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp10, ::exp10)
512 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
log, ::
log)
513 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log2, ::log2)
514 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log10, ::log10)
515 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
sin, ::
sin)
516 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
cos, ::
cos)
517 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
tan, ::
tan)
518 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
asin, ::
asin)
519 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
acos, ::
acos)
520 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
atan, ::
atan)
521 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
sinh, ::
sinh)
522 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
cosh, ::
cosh)
523 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
tanh, ::
tanh)
524 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
asinh, ::
asinh)
525 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
acosh, ::
acosh)
526 OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(
atanh, ::
atanh)
528 OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(hypot, ::hypot)
529 OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(atan2, ::atan2)
530 OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(
pow, ::
pow)
532 #undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR
533 #undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR_NO_DOUBLE
534 #undef OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR
536 template<
typename T>
struct hypot_sqr_func : binary_function<T, T, float>
538 __device__ __forceinline__
T operator ()(
typename TypeTraits<T>::ParameterType
src1,
typename TypeTraits<T>::ParameterType
src2)
const
542 __host__ __device__ __forceinline__ hypot_sqr_func() {}
543 __host__ __device__ __forceinline__ hypot_sqr_func(
const hypot_sqr_func&) {}
547 template <
typename T,
typename D>
struct saturate_cast_func : unary_function<T, D>
549 __device__ __forceinline__ D operator ()(
typename TypeTraits<T>::ParameterType v)
const
551 return saturate_cast<D>(v);
553 __host__ __device__ __forceinline__ saturate_cast_func() {}
554 __host__ __device__ __forceinline__ saturate_cast_func(
const saturate_cast_func&) {}
558 template <
typename T>
struct thresh_binary_func : unary_function<T, T>
560 __host__ __device__ __forceinline__ thresh_binary_func(
T thresh_,
T maxVal_) : thresh(thresh_), maxVal(maxVal_) {}
562 __device__ __forceinline__
T operator()(
typename TypeTraits<T>::ParameterType src)
const
564 return (src > thresh) * maxVal;
567 __host__ __device__ __forceinline__ thresh_binary_func() {}
568 __host__ __device__ __forceinline__ thresh_binary_func(
const thresh_binary_func& other)
569 : thresh(other.thresh), maxVal(other.maxVal) {}
575 template <
typename T>
struct thresh_binary_inv_func : unary_function<T, T>
577 __host__ __device__ __forceinline__ thresh_binary_inv_func(
T thresh_,
T maxVal_) : thresh(thresh_), maxVal(maxVal_) {}
579 __device__ __forceinline__
T operator()(
typename TypeTraits<T>::ParameterType src)
const
581 return (src <= thresh) * maxVal;
584 __host__ __device__ __forceinline__ thresh_binary_inv_func() {}
585 __host__ __device__ __forceinline__ thresh_binary_inv_func(
const thresh_binary_inv_func& other)
586 : thresh(other.thresh), maxVal(other.maxVal) {}
592 template <
typename T>
struct thresh_trunc_func : unary_function<T, T>
594 explicit __host__ __device__ __forceinline__ thresh_trunc_func(
T thresh_,
T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);}
596 __device__ __forceinline__
T operator()(
typename TypeTraits<T>::ParameterType src)
const
598 return minimum<T>()(src, thresh);
601 __host__ __device__ __forceinline__ thresh_trunc_func() {}
602 __host__ __device__ __forceinline__ thresh_trunc_func(
const thresh_trunc_func& other)
603 : thresh(other.thresh) {}
608 template <
typename T>
struct thresh_to_zero_func : unary_function<T, T>
610 explicit __host__ __device__ __forceinline__ thresh_to_zero_func(
T thresh_,
T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);}
612 __device__ __forceinline__
T operator()(
typename TypeTraits<T>::ParameterType src)
const
614 return (src > thresh) * src;
617 __host__ __device__ __forceinline__ thresh_to_zero_func() {}
618 __host__ __device__ __forceinline__ thresh_to_zero_func(
const thresh_to_zero_func& other)
619 : thresh(other.thresh) {}
624 template <
typename T>
struct thresh_to_zero_inv_func : unary_function<T, T>
626 explicit __host__ __device__ __forceinline__ thresh_to_zero_inv_func(
T thresh_,
T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);}
628 __device__ __forceinline__
T operator()(
typename TypeTraits<T>::ParameterType src)
const
630 return (src <= thresh) * src;
633 __host__ __device__ __forceinline__ thresh_to_zero_inv_func() {}
634 __host__ __device__ __forceinline__ thresh_to_zero_inv_func(
const thresh_to_zero_inv_func& other)
635 : thresh(other.thresh) {}
641 template <
typename Predicate>
struct unary_negate : unary_function<typename Predicate::argument_type, bool>
643 explicit __host__ __device__ __forceinline__ unary_negate(
const Predicate& p) : pred(p) {}
645 __device__ __forceinline__
bool operator()(
typename TypeTraits<typename Predicate::argument_type>::ParameterType
x)
const
650 __host__ __device__ __forceinline__ unary_negate() {}
651 __host__ __device__ __forceinline__ unary_negate(
const unary_negate& other) : pred(other.pred) {}
656 template <
typename Predicate> __host__ __device__ __forceinline__ unary_negate<Predicate>
not1(
const Predicate& pred)
658 return unary_negate<Predicate>(pred);
661 template <
typename Predicate>
struct binary_negate : binary_function<typename Predicate::first_argument_type, typename Predicate::second_argument_type, bool>
663 explicit __host__ __device__ __forceinline__ binary_negate(
const Predicate& p) : pred(p) {}
665 __device__ __forceinline__
bool operator()(
typename TypeTraits<typename Predicate::first_argument_type>::ParameterType
x,
666 typename TypeTraits<typename Predicate::second_argument_type>::ParameterType
y)
const
671 __host__ __device__ __forceinline__ binary_negate() {}
672 __host__ __device__ __forceinline__ binary_negate(
const binary_negate& other) : pred(other.pred) {}
677 template <
typename BinaryPredicate> __host__ __device__ __forceinline__ binary_negate<BinaryPredicate>
not2(
const BinaryPredicate& pred)
679 return binary_negate<BinaryPredicate>(pred);
682 template <
typename Op>
struct binder1st : unary_function<typename Op::second_argument_type, typename Op::result_type>
684 __host__ __device__ __forceinline__ binder1st(
const Op& op_,
const typename Op::first_argument_type& arg1_) : op(op_), arg1(arg1_) {}
686 __device__ __forceinline__
typename Op::result_type operator ()(
typename TypeTraits<typename Op::second_argument_type>::ParameterType a)
const
691 __host__ __device__ __forceinline__ binder1st() {}
692 __host__ __device__ __forceinline__ binder1st(
const binder1st& other) : op(other.op), arg1(other.arg1) {}
695 typename Op::first_argument_type arg1;
698 template <
typename Op,
typename T> __host__ __device__ __forceinline__ binder1st<Op> bind1st(
const Op& op,
const T&
x)
700 return binder1st<Op>(op,
typename Op::first_argument_type(
x));
703 template <
typename Op>
struct binder2nd : unary_function<typename Op::first_argument_type, typename Op::result_type>
705 __host__ __device__ __forceinline__ binder2nd(
const Op& op_,
const typename Op::second_argument_type& arg2_) : op(op_), arg2(arg2_) {}
707 __forceinline__ __device__
typename Op::result_type operator ()(
typename TypeTraits<typename Op::first_argument_type>::ParameterType a)
const
712 __host__ __device__ __forceinline__ binder2nd() {}
713 __host__ __device__ __forceinline__ binder2nd(
const binder2nd& other) : op(other.op), arg2(other.arg2) {}
716 typename Op::second_argument_type arg2;
719 template <
typename Op,
typename T> __host__ __device__ __forceinline__ binder2nd<Op> bind2nd(
const Op& op,
const T&
x)
721 return binder2nd<Op>(op,
typename Op::second_argument_type(
x));
725 template <
typename F>
struct IsUnaryFunction
728 struct No {Yes a[2];};
730 template <
typename T,
typename D>
static Yes check(unary_function<T, D>);
731 static No check(...);
735 enum {
value = (
sizeof(check(makeF())) ==
sizeof(Yes)) };
738 template <
typename F>
struct IsBinaryFunction
741 struct No {Yes a[2];};
743 template <
typename T1,
typename T2,
typename D>
static Yes check(binary_function<T1, T2, D>);
744 static No check(...);
748 enum {
value = (
sizeof(check(makeF())) ==
sizeof(Yes)) };
751 namespace functional_detail
753 template <
size_t src_elem_size,
size_t dst_elem_size>
struct UnOpShift {
enum { shift = 1 }; };
754 template <
size_t src_elem_size>
struct UnOpShift<src_elem_size, 1> {
enum { shift = 4 }; };
755 template <
size_t src_elem_size>
struct UnOpShift<src_elem_size, 2> {
enum { shift = 2 }; };
757 template <
typename T,
typename D>
struct DefaultUnaryShift
759 enum { shift = UnOpShift<
sizeof(
T),
sizeof(D)>::shift };
762 template <
size_t src_elem_size1,
size_t src_elem_size2,
size_t dst_elem_size>
struct BinOpShift {
enum { shift = 1 }; };
763 template <
size_t src_elem_size1,
size_t src_elem_size2>
struct BinOpShift<src_elem_size1, src_elem_size2, 1> {
enum { shift = 4 }; };
764 template <
size_t src_elem_size1,
size_t src_elem_size2>
struct BinOpShift<src_elem_size1, src_elem_size2, 2> {
enum { shift = 2 }; };
766 template <
typename T1,
typename T2,
typename D>
struct DefaultBinaryShift
768 enum { shift = BinOpShift<
sizeof(T1),
sizeof(T2),
sizeof(D)>::shift };
772 template <
typename Func>
struct ShiftDispatcher<Func, true>
774 enum { shift = DefaultUnaryShift<typename Func::argument_type, typename Func::result_type>::shift };
776 template <
typename Func>
struct ShiftDispatcher<Func, false>
778 enum { shift = DefaultBinaryShift<typename Func::first_argument_type, typename Func::second_argument_type, typename Func::result_type>::shift };
782 template <
typename Func>
struct DefaultTransformShift
784 enum { shift = functional_detail::ShiftDispatcher<Func>::shift };
787 template <
typename Func>
struct DefaultTransformFunctorTraits
789 enum { simple_block_dim_x = 16 };
790 enum { simple_block_dim_y = 16 };
792 enum { smart_block_dim_x = 16 };
793 enum { smart_block_dim_y = 16 };
794 enum { smart_shift = DefaultTransformShift<Func>::shift };
797 template <
typename Func>
struct TransformFunctorTraits : DefaultTransformFunctorTraits<Func> {};
799 #define OPENCV_CUDA_TRANSFORM_FUNCTOR_TRAITS(type) \
800 template <> struct TransformFunctorTraits< type > : DefaultTransformFunctorTraits< type >
InputArrayOfArrays InputArrayOfArrays InputOutputArray InputOutputArray InputOutputArray InputOutputArray Size InputOutputArray InputOutputArray T
Definition: calib3d.hpp:1867
InputArrayOfArrays InputArrayOfArrays InputOutputArray InputOutputArray InputOutputArray InputOutputArray Size InputOutputArray InputOutputArray OutputArray OutputArray F
Definition: calib3d.hpp:1867
int CvScalar value
Definition: core_c.h:720
const CvArr const CvArr * src2
Definition: core_c.h:994
const CvArr * src1
Definition: core_c.h:993
const CvArr CvArr * x
Definition: core_c.h:1195
const CvArr * y
Definition: core_c.h:1187
signed char schar
Definition: interface.h:48
uint32_t uint
Definition: interface.h:42
unsigned char uchar
Definition: interface.h:51
unsigned short ushort
Definition: interface.h:52
softfloat abs(softfloat a)
Absolute value.
Definition: softfloat.hpp:444
softfloat max(const softfloat &a, const softfloat &b)
Definition: softfloat.hpp:440
softfloat min(const softfloat &a, const softfloat &b)
Min and Max functions.
Definition: softfloat.hpp:437
CV_EXPORTS softfloat pow(const softfloat &a, const softfloat &b)
Raising to the power.
Quat< T > asinh(const Quat< T > &q)
Quat< T > tanh(const Quat< T > &q)
Quat< T > acosh(const Quat< T > &q)
Quat< T > acos(const Quat< T > &q)
Quat< T > tan(const Quat< T > &q)
Quat< T > sin(const Quat< T > &q)
Quat< T > atan(const Quat< T > &q)
Quat< T > asin(const Quat< T > &q)
Quat< T > sinh(const Quat< T > &q)
Quat< S > sqrt(const Quat< S > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
Quat< T > cosh(const Quat< T > &q)
Quat< T > atanh(const Quat< T > &q)
Quat< T > cos(const Quat< T > &q)
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441
DualQuat< T > log(const DualQuat< T > &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
Definition: dualquaternion.inl.hpp:344
DualQuat< T > exp(const DualQuat< T > &dq)
Definition: dualquaternion.inl.hpp:312
static uchar abs(uchar a)
Definition: cvstd.hpp:66