87 PyObject* input1_array = PyArray_FROM_OTF(input1,detail::NumpyTraits<TArgument1>::getCode(),
89 PyObject* input2_array = PyArray_FROM_OTF(input2,detail::NumpyTraits<TArgument1>::getCode(),
91 if (input1_array == NULL || input2_array == NULL) {
92 Py_XDECREF(input1_array);
93 Py_XDECREF(input2_array);
96 PyObject* output_array;
97 if (output == NULL || output == Py_None) {
98 PyObject* tmp = PyArray_MultiIterNew(2,input1_array,input2_array);
100 Py_XDECREF(input1_array);
101 Py_XDECREF(input2_array);
104 PyArrayMultiIterObject* tmp_iter = (PyArrayMultiIterObject*)tmp;
105 output_array = PyArray_SimpleNew(tmp_iter->nd,tmp_iter->dimensions,
106 detail::NumpyTraits<TResult>::getCode());
109 output_array = PyArray_FROM_OTF(output,detail::NumpyTraits<TResult>::getCode(),
110 NPY_ALIGNED | NPY_WRITEABLE | NPY_UPDATEIFCOPY);
112 if (output_array == NULL) {
113 Py_DECREF(input1_array);
114 Py_DECREF(input2_array);
117 PyObject*
iter = PyArray_MultiIterNew(3,input1_array,input2_array,output_array);
119 Py_DECREF(input1_array);
120 Py_DECREF(input2_array);
121 Py_DECREF(output_array);
124 int size = ((PyArrayMultiIterObject*)(iter))->size;
126 TArgument1* arg1 = (TArgument1*)PyArray_MultiIter_DATA(iter,0);
127 TArgument2* arg2 = (TArgument2*)PyArray_MultiIter_DATA(iter,1);
128 TResult* res = (TResult*)PyArray_MultiIter_DATA(iter,2);
129 *res =
self(*arg1,*arg2);
130 PyArray_MultiIter_NEXT(iter);
132 Py_DECREF(input1_array);
133 Py_DECREF(input2_array);
135 return PyArray_Return(reinterpret_cast<PyArrayObject*>(output_array));