| 791 | |
| 792 | template <typename InType, typename OutType, typename Functor> |
| 793 | struct BinaryUFunc { |
| 794 | static std::vector<int> Types() { |
| 795 | return {TypeDescriptor<InType>::Dtype(), TypeDescriptor<InType>::Dtype(), |
| 796 | TypeDescriptor<OutType>::Dtype()}; |
| 797 | } |
| 798 | static void Call(char** args, npy_intp* dimensions, npy_intp* steps, |
| 799 | void* data) { |
| 800 | const char* i0 = args[0]; |
| 801 | const char* i1 = args[1]; |
| 802 | char* o = args[2]; |
| 803 | for (npy_intp k = 0; k < *dimensions; k++) { |
| 804 | auto x = *reinterpret_cast<const typename TypeDescriptor<InType>::T*>(i0); |
| 805 | auto y = *reinterpret_cast<const typename TypeDescriptor<InType>::T*>(i1); |
| 806 | *reinterpret_cast<typename TypeDescriptor<OutType>::T*>(o) = |
| 807 | Functor()(x, y); |
| 808 | i0 += steps[0]; |
| 809 | i1 += steps[1]; |
| 810 | o += steps[2]; |
| 811 | } |
| 812 | } |
| 813 | }; |
| 814 | |
| 815 | template <typename InType, typename InType2, typename OutType, typename Functor> |
| 816 | struct BinaryUFunc2 { |