LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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: