8 #ifndef _PyImathOperators_h_
9 #define _PyImathOperators_h_
16 template <
class T1,
class T2=T1,
class Ret=T1>
18 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a+
b; }
21 template <
class T1,
class T2=T1,
class Ret=T1>
23 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a-
b; }
26 template <
class T1,
class T2=T1,
class Ret=T1>
28 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return b-
a; }
31 template <
class T1,
class T2=T1,
class Ret=T1>
33 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a*
b; }
36 template <
class T1,
class T2=T1,
class Ret=T1>
38 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a/
b; }
41 template <
class T1,
class T2=T1,
class Ret=T1>
43 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a%
b; }
46 template <
class T1,
class T2=T1,
class Ret=T1>
51 template <
class T1,
class T2=T1,
class Ret=T1>
56 template <
class T1,
class Ret=T1>
58 static inline Ret
apply(
const T1 &
a) {
return -
a; }
61 template <
class T1,
class Ret=T1>
66 template <
class T1,
class Ret=T1>
68 static inline Ret
apply(
const T1 &
a) {
return ~a; }
71 template <
class T1,
class T2=T1,
class Ret=T1>
73 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a <<
b; }
76 template <
class T1,
class T2=T1,
class Ret=T1>
78 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a >>
b; }
81 template <
class T1,
class T2=T1,
class Ret=T1>
83 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a &
b; }
86 template <
class T1,
class T2=T1,
class Ret=T1>
88 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a ^
b; }
91 template <
class T1,
class T2=T1,
class Ret=T1>
93 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a |
b; }
96 template <
class T1,
class T2=T1>
98 static inline void apply(T1 &
a,
const T2 &
b) { a +=
b; }
101 template <
class T1,
class T2=T1>
103 static inline void apply(T1 &
a,
const T2 &
b) { a -=
b; }
106 template <
class T1,
class T2=T1>
108 static inline void apply(T1 &
a,
const T2 &
b) { a *=
b; }
111 template <
class T1,
class T2=T1>
113 static inline void apply(T1 &
a,
const T2 &
b) { a /=
b; }
116 template <
class T1,
class T2=T1>
118 static inline void apply(T1 &
a,
const T2 &
b) { a %=
b; }
121 template <
class T1,
class T2=T1>
126 template <
class T1,
class T2=T1>
128 static inline void apply(T1 &
a,
const T2 &
b) { a <<=
b; }
131 template <
class T1,
class T2=T1>
133 static inline void apply(T1 &
a,
const T2 &
b) { a >>=
b; }
136 template <
class T1,
class T2=T1>
138 static inline void apply(T1 &
a,
const T2 &
b) { a ^=
b; }
141 template <
class T1,
class T2=T1>
143 static inline void apply(T1 &
a,
const T2 &
b) { a &=
b; }
146 template <
class T1,
class T2=T1>
148 static inline void apply(T1 &
a,
const T2 &
b) { a |=
b; }
153 template <
class T1,
class T2=T1,
class Ret=
int>
155 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a <
b; }
158 template <
class T1,
class T2=T1,
class Ret=
int>
160 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a >
b; }
163 template <
class T1,
class T2=T1,
class Ret=
int>
165 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a <=
b; }
168 template <
class T1,
class T2=T1,
class Ret=
int>
170 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a >=
b; }
173 template <
class T1,
class T2=T1,
class Ret=
int>
175 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a ==
b; }
178 template <
class T1,
class T2=T1,
class Ret=
int>
180 static inline Ret
apply(
const T1 &
a,
const T2 &
b) {
return a !=
b; }
184 static T fa_reduce(
const FixedArray<T> &
a) {
186 size_t len = a.len();
187 for (
size_t i=0; i < len; ++i) tmp += a[i];
192 static T fa_min(
const FixedArray<T> &a) {
194 size_t len = a.len();
197 for (
size_t i=1; i < len; ++i)
204 static T fa_max(
const FixedArray<T> &a) {
206 size_t len = a.len();
209 for (
size_t i=1; i < len; ++i)
216 static void add_arithmetic_math_functions(hboost::python::class_<FixedArray<T> > &
c) {
217 using hboost::mpl::true_;
218 using hboost::mpl::false_;
227 generate_member_bindings<op_neg<T> >(
c,
"__neg__",
"-x");
234 c.def(
"reduce",&fa_reduce<T>);
238 static void add_reduction_functions(hboost::python::class_<FixedArray<T> > &c) {
239 c.def(
"min",&fa_min<T>);
240 c.def(
"max",&fa_max<T>);
244 static void add_pow_math_functions(hboost::python::class_<FixedArray<T> > &c) {
245 using hboost::mpl::true_;
246 using hboost::mpl::false_;
253 static void add_mod_math_functions(hboost::python::class_<FixedArray<T> > &c) {
254 using hboost::mpl::true_;
260 static void add_shift_math_functions(hboost::python::class_<FixedArray<T> > &c) {
261 using hboost::mpl::true_;
269 static void add_bitwise_math_functions(hboost::python::class_<FixedArray<T> > &c) {
270 using hboost::mpl::true_;
280 static void add_comparison_functions(hboost::python::class_<FixedArray<T> > &c) {
281 using hboost::mpl::true_;
287 static void add_ordered_comparison_functions(hboost::python::class_<FixedArray<T> > &c) {
288 using hboost::mpl::true_;
295 template <
class S,
class T>
296 static void add_explicit_construction_from_type(hboost::python::class_<FixedArray<T> > &c) {
297 using namespace hboost::python;
298 c.def(init<FixedArray<S> >(
"copy contents of other array into this one"));
303 #endif // _PyImathOperators_h_
static void apply(T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a)
GLboolean GLboolean GLboolean GLboolean a
static Ret apply(const T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
ImageBuf OIIO_API pow(const ImageBuf &A, cspan< float > B, ROI roi={}, int nthreads=0)
static void apply(T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)
GLboolean GLboolean GLboolean b
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a)
static Ret apply(const T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
**If you just want to fire and args
static void apply(T1 &a, const T2 &b)
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
static Ret apply(const T1 &a)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static Ret apply(const T1 &a, const T2 &b)
static void apply(T1 &a, const T2 &b)