LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Static Public Member Functions | List of all members
ndarray::PyBinaryUFunctor< TBinaryFunctor, TArgument1, TArgument2, TResult > Struct Template Reference

#include <ufunctors.h>

Static Public Member Functions

static PyObject * _call_ (TBinaryFunctor const &self, PyObject *input1, PyObject *input2, PyObject *output)
 

Detailed Description

template<typename TBinaryFunctor, typename TArgument1 = typename TBinaryFunctor::first_argument_type, typename TArgument2 = typename TBinaryFunctor::second_argument_type, typename TResult = typename TBinaryFunctor::result_type>
struct ndarray::PyBinaryUFunctor< TBinaryFunctor, TArgument1, TArgument2, TResult >

Definition at line 83 of file ufunctors.h.

Member Function Documentation

template<typename TBinaryFunctor , typename TArgument1 = typename TBinaryFunctor::first_argument_type, typename TArgument2 = typename TBinaryFunctor::second_argument_type, typename TResult = typename TBinaryFunctor::result_type>
static PyObject* ndarray::PyBinaryUFunctor< TBinaryFunctor, TArgument1, TArgument2, TResult >::_call_ ( TBinaryFunctor const &  self,
PyObject *  input1,
PyObject *  input2,
PyObject *  output 
)
inlinestatic

Definition at line 85 of file ufunctors.h.

86  {
87  PyObject* input1_array = PyArray_FROM_OTF(input1,detail::NumpyTraits<TArgument1>::getCode(),
88  NPY_ALIGNED);
89  PyObject* input2_array = PyArray_FROM_OTF(input2,detail::NumpyTraits<TArgument1>::getCode(),
90  NPY_ALIGNED);
91  if (input1_array == NULL || input2_array == NULL) {
92  Py_XDECREF(input1_array);
93  Py_XDECREF(input2_array);
94  return NULL;
95  }
96  PyObject* output_array;
97  if (output == NULL || output == Py_None) {
98  PyObject* tmp = PyArray_MultiIterNew(2,input1_array,input2_array);
99  if (tmp == NULL) {
100  Py_XDECREF(input1_array);
101  Py_XDECREF(input2_array);
102  return NULL;
103  }
104  PyArrayMultiIterObject* tmp_iter = (PyArrayMultiIterObject*)tmp;
105  output_array = PyArray_SimpleNew(tmp_iter->nd,tmp_iter->dimensions,
106  detail::NumpyTraits<TResult>::getCode());
107  Py_DECREF(tmp);
108  } else {
109  output_array = PyArray_FROM_OTF(output,detail::NumpyTraits<TResult>::getCode(),
110  NPY_ALIGNED | NPY_WRITEABLE | NPY_UPDATEIFCOPY);
111  }
112  if (output_array == NULL) {
113  Py_DECREF(input1_array);
114  Py_DECREF(input2_array);
115  return NULL;
116  }
117  PyObject* iter = PyArray_MultiIterNew(3,input1_array,input2_array,output_array);
118  if (iter == NULL) {
119  Py_DECREF(input1_array);
120  Py_DECREF(input2_array);
121  Py_DECREF(output_array);
122  return NULL;
123  }
124  int size = ((PyArrayMultiIterObject*)(iter))->size;
125  while (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);
131  }
132  Py_DECREF(input1_array);
133  Py_DECREF(input2_array);
134  Py_DECREF(iter);
135  return PyArray_Return(reinterpret_cast<PyArrayObject*>(output_array));
136  }
int iter

The documentation for this struct was generated from the following file: