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::PyUnaryUFunctor< TUnaryFunctor, TArgument, TResult > Struct Template Reference

#include <ufunctors.h>

Static Public Member Functions

static PyObject * _call_ (TUnaryFunctor const &self, PyObject *input, PyObject *output)
 

Detailed Description

template<typename TUnaryFunctor, typename TArgument = typename TUnaryFunctor::argument_type, typename TResult = typename TUnaryFunctor::result_type>
struct ndarray::PyUnaryUFunctor< TUnaryFunctor, TArgument, TResult >

Definition at line 39 of file ufunctors.h.

Member Function Documentation

template<typename TUnaryFunctor , typename TArgument = typename TUnaryFunctor::argument_type, typename TResult = typename TUnaryFunctor::result_type>
static PyObject* ndarray::PyUnaryUFunctor< TUnaryFunctor, TArgument, TResult >::_call_ ( TUnaryFunctor const &  self,
PyObject *  input,
PyObject *  output 
)
inlinestatic

Definition at line 41 of file ufunctors.h.

41  {
42  PyObject* input_array = PyArray_FROM_OTF(input,detail::NumpyTraits<TArgument>::getCode(),
43  NPY_ALIGNED);
44  if (input_array == NULL) return NULL;
45  PyObject* output_array;
46  if (output == NULL || output == Py_None) {
47  output_array = PyArray_SimpleNew(PyArray_NDIM(input_array),
48  PyArray_DIMS(input_array),
49  detail::NumpyTraits<TResult>::getCode());
50  } else {
51  output_array = PyArray_FROM_OTF(output,detail::NumpyTraits<TResult>::getCode(),
52  NPY_ALIGNED | NPY_WRITEABLE | NPY_UPDATEIFCOPY);
53  }
54  if (output_array == NULL) {
55  Py_DECREF(input_array);
56  return NULL;
57  }
58  PyObject* iter = PyArray_MultiIterNew(2,input_array,output_array);
59  if (iter == NULL) {
60  Py_DECREF(input_array);
61  Py_DECREF(output_array);
62  return NULL;
63  }
64  int size = ((PyArrayMultiIterObject*)(iter))->size;
65  while (size--) {
66  TArgument* arg = (TArgument*)PyArray_MultiIter_DATA(iter,0);
67  TResult* res = (TResult*)PyArray_MultiIter_DATA(iter,1);
68  *res = self(*arg);
69  PyArray_MultiIter_NEXT(iter);
70  }
71  Py_DECREF(input_array);
72  Py_DECREF(iter);
73  return PyArray_Return(reinterpret_cast<PyArrayObject*>(output_array));
74  }
int iter

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