Generated by Cython 0.15.1+ on Wed Dec 21 21:48:02 2011

Raw output: bilinear.c

     1: # -*- coding: utf8 -*-

      /* "bilinear.pyx":1
     * # -*- coding: utf8 -*-             # <<<<<<<<<<<<<<
     * #
     * #    Project: Azimuthal integration
     */
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

     2: #

     3: #    Project: Azimuthal integration

     4: #             https://forge.epn-campus.eu/projects/azimuthal

     5: #

     6: #    File: "$Id$"

     7: #

     8: #    Copyright (C) European Synchrotron Radiation Facility, Grenoble, France

     9: #

     10: #    Principal author:       Jérôme Kieffer (Jerome.Kieffer@ESRF.eu)

     11: #

     12: #    This program is free software: you can redistribute it and/or modify

     13: #    it under the terms of the GNU General Public License as published by

     14: #    the Free Software Foundation, either version 3 of the License, or

     15: #    (at your option) any later version.

     16: #

     17: #    This program is distributed in the hope that it will be useful,

     18: #    but WITHOUT ANY WARRANTY; without even the implied warranty of

     19: #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

     20: #    GNU General Public License for more details.

     21: #

     22: #    You should have received a copy of the GNU General Public License

     23: #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

     24: #

     25:

     26: __author__ = "Jerome Kieffer"

      /* "bilinear.pyx":26
     * #
     *
     * __author__ = "Jerome Kieffer"             # <<<<<<<<<<<<<<
     * __license__ = "GPLv3"
     * __date__ = "21/12/2011"
     */
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s____author__, ((PyObject *)__pyx_kp_s_14)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     27: __license__ = "GPLv3"

      /* "bilinear.pyx":27
     *
     * __author__ = "Jerome Kieffer"
     * __license__ = "GPLv3"             # <<<<<<<<<<<<<<
     * __date__ = "21/12/2011"
     * __copyright__ = "2011, ESRF"
     */
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s____license__, ((PyObject *)__pyx_n_s__GPLv3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     28: __date__ = "21/12/2011"

      /* "bilinear.pyx":28
     * __author__ = "Jerome Kieffer"
     * __license__ = "GPLv3"
     * __date__ = "21/12/2011"             # <<<<<<<<<<<<<<
     * __copyright__ = "2011, ESRF"
     * __contact__ = "jerome.kieffer@esrf.fr"
     */
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s____date__, ((PyObject *)__pyx_kp_s_15)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     29: __copyright__ = "2011, ESRF"

      /* "bilinear.pyx":29
     * __license__ = "GPLv3"
     * __date__ = "21/12/2011"
     * __copyright__ = "2011, ESRF"             # <<<<<<<<<<<<<<
     * __contact__ = "jerome.kieffer@esrf.fr"
     *
     */
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s____copyright__, ((PyObject *)__pyx_kp_s_16)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     30: __contact__ = "jerome.kieffer@esrf.fr"

      /* "bilinear.pyx":30
     * __date__ = "21/12/2011"
     * __copyright__ = "2011, ESRF"
     * __contact__ = "jerome.kieffer@esrf.fr"             # <<<<<<<<<<<<<<
     *
     * import cython
     */
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s____contact__, ((PyObject *)__pyx_kp_s_17)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     31:

     32: import cython

     33: cimport numpy

     34: import numpy

      /* "bilinear.pyx":34
     * import cython
     * cimport numpy
     * import numpy             # <<<<<<<<<<<<<<
     * ctypedef numpy.float32_t DTYPE_float32_t
     *
     */
      __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__numpy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     35: ctypedef numpy.float32_t DTYPE_float32_t

     36:

     37: cdef extern from "math.h":

     38:     float floor(float) nogil

     39:     float ceil(float) nogil

     40: cdef extern from "stdlib.h":

     41:     void free(void * ptr)nogil

     42:     void * calloc(size_t nmemb, size_t size)nogil

     43:     void * malloc(size_t size)nogil

     44:     void * memcpy(void * dst, void * src, long n)

     45: cdef extern from "numpy/arrayobject.h":

     46:     ctypedef int intp

     47:     ctypedef extern class numpy.ndarray [object PyArrayObject]:

     48:         cdef char * data

     49:         cdef int nd

     50:         cdef intp * dimensions

     51:         cdef intp * strides

     52:         cdef int flags

     53:

     54: @cython.boundscheck(False)

     55: cdef class bilinear:

     56:     """Bilinear interpolator for finding max"""

     57:

     58:     cdef float * data

     59:     cdef float max, min

     60:     cdef long d0_max, d1_max, r

     61:

     62:     def __dealloc__(self):

    /* "bilinear.pyx":62
     *     cdef long d0_max, d1_max, r
     *
     *     def __dealloc__(self):             # <<<<<<<<<<<<<<
     *         free(self.data)
     *
     */

    static void __pyx_pf_8bilinear_8bilinear___dealloc__(PyObject *__pyx_v_self); /*proto*/
    static void __pyx_pf_8bilinear_8bilinear___dealloc__(PyObject *__pyx_v_self) {
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__dealloc__");

     63:         free(self.data)

      /* "bilinear.pyx":63
     *
     *     def __dealloc__(self):
     *         free(self.data)             # <<<<<<<<<<<<<<
     *
     *     def __init__(self, numpy.ndarray data not None):
     */
      free(((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data);

      __Pyx_RefNannyFinishContext();
    }

     64:

     65:     def __init__(self, numpy.ndarray data not None):

    /* "bilinear.pyx":65
     *         free(self.data)
     *
     *     def __init__(self, numpy.ndarray data not None):             # <<<<<<<<<<<<<<
     *         assert data.ndim == 2
     *         self.d0_max = data.shape[0] - 1
     */

    static int __pyx_pf_8bilinear_8bilinear_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static int __pyx_pf_8bilinear_8bilinear_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_data = 0;
      PyArrayObject *__pyx_v_data2 = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_data2;
      __Pyx_Buffer __pyx_pybuffer_data2;
      int __pyx_r;
      static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__data,0};
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__init__");
      {
        PyObject* values[1] = {0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
            if (likely(values[0])) kw_args--;
            else goto __pyx_L5_argtuple_error;
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
          __pyx_v_data = ((PyArrayObject *)values[0]);
        } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        }
        __pyx_v_data = ((PyArrayObject *)values[0]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_L3_error:;
      __Pyx_AddTraceback("bilinear.bilinear.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return -1;
      __pyx_L4_argument_unpacking_done:;
      __pyx_pybuffer_data2.pybuffer.buf = NULL;
      __pyx_pybuffer_data2.refcount = 0;
      __pyx_pybuffernd_data2.data = NULL;
      __pyx_pybuffernd_data2.rcbuffer = &__pyx_pybuffer_data2;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), __pyx_ptype_5numpy_ndarray, 0, "data", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

     66:         assert data.ndim == 2

      /* "bilinear.pyx":66
     *
     *     def __init__(self, numpy.ndarray data not None):
     *         assert data.ndim == 2             # <<<<<<<<<<<<<<
     *         self.d0_max = data.shape[0] - 1
     *         self.d1_max = data.shape[1] - 1
     */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!(__pyx_v_data->nd == 2))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

     67:         self.d0_max = data.shape[0] - 1

      /* "bilinear.pyx":67
     *     def __init__(self, numpy.ndarray data not None):
     *         assert data.ndim == 2
     *         self.d0_max = data.shape[0] - 1             # <<<<<<<<<<<<<<
     *         self.d1_max = data.shape[1] - 1
     *         self.r = data.shape[1]
     */
      ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->d0_max = ((__pyx_v_data->dimensions[0]) - 1);

     68:         self.d1_max = data.shape[1] - 1

      /* "bilinear.pyx":68
     *         assert data.ndim == 2
     *         self.d0_max = data.shape[0] - 1
     *         self.d1_max = data.shape[1] - 1             # <<<<<<<<<<<<<<
     *         self.r = data.shape[1]
     *         self.max = data.max()
     */
      ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->d1_max = ((__pyx_v_data->dimensions[1]) - 1);

     69:         self.r = data.shape[1]

      /* "bilinear.pyx":69
     *         self.d0_max = data.shape[0] - 1
     *         self.d1_max = data.shape[1] - 1
     *         self.r = data.shape[1]             # <<<<<<<<<<<<<<
     *         self.max = data.max()
     *         self.min = data.min()
     */
      ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r = (__pyx_v_data->dimensions[1]);

     70:         self.max = data.max()

      /* "bilinear.pyx":70
     *         self.d1_max = data.shape[1] - 1
     *         self.r = data.shape[1]
     *         self.max = data.max()             # <<<<<<<<<<<<<<
     *         self.min = data.min()
     *         self.data = < float *> malloc(data.size * sizeof(float))
     */
      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_data), __pyx_n_s__max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->max = __pyx_t_3;

     71:         self.min = data.min()

      /* "bilinear.pyx":71
     *         self.r = data.shape[1]
     *         self.max = data.max()
     *         self.min = data.min()             # <<<<<<<<<<<<<<
     *         self.data = < float *> malloc(data.size * sizeof(float))
     *         cdef numpy.ndarray[DTYPE_float32_t, ndim = 2] data2 = numpy.ascontiguousarray(data.astype("float32"))
     */
      __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_data), __pyx_n_s__min); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->min = __pyx_t_3;

     72:         self.data = < float *> malloc(data.size * sizeof(float))

      /* "bilinear.pyx":72
     *         self.max = data.max()
     *         self.min = data.min()
     *         self.data = < float *> malloc(data.size * sizeof(float))             # <<<<<<<<<<<<<<
     *         cdef numpy.ndarray[DTYPE_float32_t, ndim = 2] data2 = numpy.ascontiguousarray(data.astype("float32"))
     *         memcpy(self.data, data2.data, data.size * sizeof(float))
     */
      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_data), __pyx_n_s__size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(float))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = __Pyx_PyInt_AsSize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data = ((float *)malloc(__pyx_t_5));

     73:         cdef numpy.ndarray[DTYPE_float32_t, ndim = 2] data2 = numpy.ascontiguousarray(data.astype("float32"))

      /* "bilinear.pyx":73
     *         self.min = data.min()
     *         self.data = < float *> malloc(data.size * sizeof(float))
     *         cdef numpy.ndarray[DTYPE_float32_t, ndim = 2] data2 = numpy.ascontiguousarray(data.astype("float32"))             # <<<<<<<<<<<<<<
     *         memcpy(self.data, data2.data, data.size * sizeof(float))
     *
     */
      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ascontiguousarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_data), __pyx_n_s__astype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_1), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data2.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_8bilinear_DTYPE_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          __pyx_v_data2 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_data2.rcbuffer->pybuffer.buf = NULL;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else {__pyx_pybuffernd_data2.diminfo[0].strides = __pyx_pybuffernd_data2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data2.diminfo[0].shape = __pyx_pybuffernd_data2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_data2.diminfo[1].strides = __pyx_pybuffernd_data2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_data2.diminfo[1].shape = __pyx_pybuffernd_data2.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_data2 = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "bilinear.pyx":73
     *         self.min = data.min()
     *         self.data = < float *> malloc(data.size * sizeof(float))
     *         cdef numpy.ndarray[DTYPE_float32_t, ndim = 2] data2 = numpy.ascontiguousarray(data.astype("float32"))             # <<<<<<<<<<<<<<
     *         memcpy(self.data, data2.data, data.size * sizeof(float))
     *
     */
      __pyx_k_tuple_1 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_k_tuple_1);
      __Pyx_INCREF(((PyObject *)__pyx_n_s__float32));
      PyTuple_SET_ITEM(__pyx_k_tuple_1, 0, ((PyObject *)__pyx_n_s__float32));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__float32));
      __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_1));

     74:         memcpy(self.data, data2.data, data.size * sizeof(float))

      /* "bilinear.pyx":74
     *         self.data = < float *> malloc(data.size * sizeof(float))
     *         cdef numpy.ndarray[DTYPE_float32_t, ndim = 2] data2 = numpy.ascontiguousarray(data.astype("float32"))
     *         memcpy(self.data, data2.data, data.size * sizeof(float))             # <<<<<<<<<<<<<<
     *
     *
     */
      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_data), __pyx_n_s__size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyInt_FromSize_t((sizeof(float))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyInt_AsLong(__pyx_t_2); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      memcpy(((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data, __pyx_v_data2->data, __pyx_t_7);

      __pyx_r = 0;
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data2.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("bilinear.bilinear.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = -1;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data2.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_data2);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     75:

     76:

     77:     def f_cy(self, x):

    /* "bilinear.pyx":77
     *
     *
     *     def f_cy(self, x):             # <<<<<<<<<<<<<<
     *         """
     *         Function f((y,x)) where f is a continuous function (y,x) are pixel coordinates
     */

    static PyObject *__pyx_pf_8bilinear_8bilinear_2f_cy(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
    static char __pyx_doc_8bilinear_8bilinear_2f_cy[] = "\n        Function f((y,x)) where f is a continuous function (y,x) are pixel coordinates\n        @param x: 2-tuple of float \n        @return: Interpolated signal from the image (negative for minimizer)\n\n        ";
    static PyObject *__pyx_pf_8bilinear_8bilinear_2f_cy(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
      float __pyx_v_d0;
      float __pyx_v_d1;
      int __pyx_v_i0;
      int __pyx_v_i1;
      int __pyx_v_j0;
      int __pyx_v_j1;
      float __pyx_v_x0;
      float __pyx_v_x1;
      float __pyx_v_y0;
      float __pyx_v_y1;
      float __pyx_v_res;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("f_cy");

     78:         """

     79:         Function f((y,x)) where f is a continuous function (y,x) are pixel coordinates

     80:         @param x: 2-tuple of float

     81:         @return: Interpolated signal from the image (negative for minimizer)

     82:

     83:         """

     84:         cdef float d0 = x[0]

      /* "bilinear.pyx":84
     *
     *         """
     *         cdef float d0 = x[0]             # <<<<<<<<<<<<<<
     *         cdef float d1 = x[1]
     *         cdef int i0, i1, j0, j1
     */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_x, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_d0 = __pyx_t_2;

     85:         cdef float d1 = x[1]

      /* "bilinear.pyx":85
     *         """
     *         cdef float d0 = x[0]
     *         cdef float d1 = x[1]             # <<<<<<<<<<<<<<
     *         cdef int i0, i1, j0, j1
     *         cdef float x0, x1, y0, y1, res
     */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_x, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_d1 = __pyx_t_2;

     86:         cdef int i0, i1, j0, j1

     87:         cdef float x0, x1, y0, y1, res

     88:         x0 = floor(d0)

      /* "bilinear.pyx":88
     *         cdef int i0, i1, j0, j1
     *         cdef float x0, x1, y0, y1, res
     *         x0 = floor(d0)             # <<<<<<<<<<<<<<
     *         x1 = ceil(d0)
     *         y0 = floor(d1)
     */
      __pyx_v_x0 = floor(__pyx_v_d0);

     89:         x1 = ceil(d0)

      /* "bilinear.pyx":89
     *         cdef float x0, x1, y0, y1, res
     *         x0 = floor(d0)
     *         x1 = ceil(d0)             # <<<<<<<<<<<<<<
     *         y0 = floor(d1)
     *         y1 = ceil(d1)
     */
      __pyx_v_x1 = ceil(__pyx_v_d0);

     90:         y0 = floor(d1)

      /* "bilinear.pyx":90
     *         x0 = floor(d0)
     *         x1 = ceil(d0)
     *         y0 = floor(d1)             # <<<<<<<<<<<<<<
     *         y1 = ceil(d1)
     *         i0 = < int > x0
     */
      __pyx_v_y0 = floor(__pyx_v_d1);

     91:         y1 = ceil(d1)

      /* "bilinear.pyx":91
     *         x1 = ceil(d0)
     *         y0 = floor(d1)
     *         y1 = ceil(d1)             # <<<<<<<<<<<<<<
     *         i0 = < int > x0
     *         i1 = < int > x1
     */
      __pyx_v_y1 = ceil(__pyx_v_d1);

     92:         i0 = < int > x0

      /* "bilinear.pyx":92
     *         y0 = floor(d1)
     *         y1 = ceil(d1)
     *         i0 = < int > x0             # <<<<<<<<<<<<<<
     *         i1 = < int > x1
     *         j0 = < int > y0
     */
      __pyx_v_i0 = ((int)__pyx_v_x0);

     93:         i1 = < int > x1

      /* "bilinear.pyx":93
     *         y1 = ceil(d1)
     *         i0 = < int > x0
     *         i1 = < int > x1             # <<<<<<<<<<<<<<
     *         j0 = < int > y0
     *         j1 = < int > y1
     */
      __pyx_v_i1 = ((int)__pyx_v_x1);

     94:         j0 = < int > y0

      /* "bilinear.pyx":94
     *         i0 = < int > x0
     *         i1 = < int > x1
     *         j0 = < int > y0             # <<<<<<<<<<<<<<
     *         j1 = < int > y1
     *         if d0 < 0:
     */
      __pyx_v_j0 = ((int)__pyx_v_y0);

     95:         j1 = < int > y1

      /* "bilinear.pyx":95
     *         i1 = < int > x1
     *         j0 = < int > y0
     *         j1 = < int > y1             # <<<<<<<<<<<<<<
     *         if d0 < 0:
     *             res = self.min + d0
     */
      __pyx_v_j1 = ((int)__pyx_v_y1);

     96:         if d0 < 0:

      /* "bilinear.pyx":96
     *         j0 = < int > y0
     *         j1 = < int > y1
     *         if d0 < 0:             # <<<<<<<<<<<<<<
     *             res = self.min + d0
     *         elif d1 < 0:
     */
      __pyx_t_3 = (__pyx_v_d0 < 0.0);
      if (__pyx_t_3) {

     97:             res = self.min + d0

        /* "bilinear.pyx":97
     *         j1 = < int > y1
     *         if d0 < 0:
     *             res = self.min + d0             # <<<<<<<<<<<<<<
     *         elif d1 < 0:
     *             res = self.min + d1
     */
        __pyx_v_res = (((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->min + __pyx_v_d0);
        goto __pyx_L5;
      }

     98:         elif d1 < 0:

      /* "bilinear.pyx":98
     *         if d0 < 0:
     *             res = self.min + d0
     *         elif d1 < 0:             # <<<<<<<<<<<<<<
     *             res = self.min + d1
     *         elif d0 > self.d0_max:
     */
      __pyx_t_3 = (__pyx_v_d1 < 0.0);
      if (__pyx_t_3) {

     99:             res = self.min + d1

        /* "bilinear.pyx":99
     *             res = self.min + d0
     *         elif d1 < 0:
     *             res = self.min + d1             # <<<<<<<<<<<<<<
     *         elif d0 > self.d0_max:
     *             res = self.min - d0 + self.d0_max
     */
        __pyx_v_res = (((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->min + __pyx_v_d1);
        goto __pyx_L5;
      }

     100:         elif d0 > self.d0_max:

      /* "bilinear.pyx":100
     *         elif d1 < 0:
     *             res = self.min + d1
     *         elif d0 > self.d0_max:             # <<<<<<<<<<<<<<
     *             res = self.min - d0 + self.d0_max
     *         elif d1 > self.d1_max:
     */
      __pyx_t_3 = (__pyx_v_d0 > ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->d0_max);
      if (__pyx_t_3) {

     101:             res = self.min - d0 + self.d0_max

        /* "bilinear.pyx":101
     *             res = self.min + d1
     *         elif d0 > self.d0_max:
     *             res = self.min - d0 + self.d0_max             # <<<<<<<<<<<<<<
     *         elif d1 > self.d1_max:
     *             res = self.min - d1 + self.d1_max
     */
        __pyx_v_res = ((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->min - __pyx_v_d0) + ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->d0_max);
        goto __pyx_L5;
      }

     102:         elif d1 > self.d1_max:

      /* "bilinear.pyx":102
     *         elif d0 > self.d0_max:
     *             res = self.min - d0 + self.d0_max
     *         elif d1 > self.d1_max:             # <<<<<<<<<<<<<<
     *             res = self.min - d1 + self.d1_max
     *         elif (i0 == i1) and (j0 == j1):
     */
      __pyx_t_3 = (__pyx_v_d1 > ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->d1_max);
      if (__pyx_t_3) {

     103:             res = self.min - d1 + self.d1_max

        /* "bilinear.pyx":103
     *             res = self.min - d0 + self.d0_max
     *         elif d1 > self.d1_max:
     *             res = self.min - d1 + self.d1_max             # <<<<<<<<<<<<<<
     *         elif (i0 == i1) and (j0 == j1):
     *             res = self.data[i0 * self.r + j0]
     */
        __pyx_v_res = ((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->min - __pyx_v_d1) + ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->d1_max);
        goto __pyx_L5;
      }

     104:         elif (i0 == i1) and (j0 == j1):

      /* "bilinear.pyx":104
     *         elif d1 > self.d1_max:
     *             res = self.min - d1 + self.d1_max
     *         elif (i0 == i1) and (j0 == j1):             # <<<<<<<<<<<<<<
     *             res = self.data[i0 * self.r + j0]
     *         elif i0 == i1:
     */
      __pyx_t_3 = (__pyx_v_i0 == __pyx_v_i1);
      if (__pyx_t_3) {
        __pyx_t_4 = (__pyx_v_j0 == __pyx_v_j1);
        __pyx_t_5 = __pyx_t_4;
      } else {
        __pyx_t_5 = __pyx_t_3;
      }
      if (__pyx_t_5) {

     105:             res = self.data[i0 * self.r + j0]

        /* "bilinear.pyx":105
     *             res = self.min - d1 + self.d1_max
     *         elif (i0 == i1) and (j0 == j1):
     *             res = self.data[i0 * self.r + j0]             # <<<<<<<<<<<<<<
     *         elif i0 == i1:
     *             res = (self.data[i0 * self.r + j0] * (y1 - d1)) + (self.data[i0 * self.r + j1] * (d1 - y0))
     */
        __pyx_v_res = (((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i0 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j0)]);
        goto __pyx_L5;
      }

     106:         elif i0 == i1:

      /* "bilinear.pyx":106
     *         elif (i0 == i1) and (j0 == j1):
     *             res = self.data[i0 * self.r + j0]
     *         elif i0 == i1:             # <<<<<<<<<<<<<<
     *             res = (self.data[i0 * self.r + j0] * (y1 - d1)) + (self.data[i0 * self.r + j1] * (d1 - y0))
     *         elif j0 == j1:
     */
      __pyx_t_5 = (__pyx_v_i0 == __pyx_v_i1);
      if (__pyx_t_5) {

     107:             res = (self.data[i0 * self.r + j0] * (y1 - d1)) + (self.data[i0 * self.r + j1] * (d1 - y0))

        /* "bilinear.pyx":107
     *             res = self.data[i0 * self.r + j0]
     *         elif i0 == i1:
     *             res = (self.data[i0 * self.r + j0] * (y1 - d1)) + (self.data[i0 * self.r + j1] * (d1 - y0))             # <<<<<<<<<<<<<<
     *         elif j0 == j1:
     *             res = (self.data[i0 * self.r + j0] * (x1 - d0)) + (self.data[i1 * self.r + j0] * (d0 - x0))
     */
        __pyx_v_res = (((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i0 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j0)]) * (__pyx_v_y1 - __pyx_v_d1)) + ((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i0 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j1)]) * (__pyx_v_d1 - __pyx_v_y0)));
        goto __pyx_L5;
      }

     108:         elif j0 == j1:

      /* "bilinear.pyx":108
     *         elif i0 == i1:
     *             res = (self.data[i0 * self.r + j0] * (y1 - d1)) + (self.data[i0 * self.r + j1] * (d1 - y0))
     *         elif j0 == j1:             # <<<<<<<<<<<<<<
     *             res = (self.data[i0 * self.r + j0] * (x1 - d0)) + (self.data[i1 * self.r + j0] * (d0 - x0))
     *         else:
     */
      __pyx_t_5 = (__pyx_v_j0 == __pyx_v_j1);
      if (__pyx_t_5) {

     109:             res = (self.data[i0 * self.r + j0] * (x1 - d0)) + (self.data[i1 * self.r + j0] * (d0 - x0))

        /* "bilinear.pyx":109
     *             res = (self.data[i0 * self.r + j0] * (y1 - d1)) + (self.data[i0 * self.r + j1] * (d1 - y0))
     *         elif j0 == j1:
     *             res = (self.data[i0 * self.r + j0] * (x1 - d0)) + (self.data[i1 * self.r + j0] * (d0 - x0))             # <<<<<<<<<<<<<<
     *         else:
     *             res = (self.data[i0 * self.r + j0] * (x1 - d0) * (y1 - d1))  \
     */
        __pyx_v_res = (((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i0 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j0)]) * (__pyx_v_x1 - __pyx_v_d0)) + ((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i1 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j0)]) * (__pyx_v_d0 - __pyx_v_x0)));
        goto __pyx_L5;
      }
      /*else*/ {

     110:         else:

     111:             res = (self.data[i0 * self.r + j0] * (x1 - d0) * (y1 - d1))  \

     112:                 + (self.data[i1 * self.r + j0] * (d0 - x0) * (y1 - d1))  \

     113:                 + (self.data[i0 * self.r + j1] * (x1 - d0) * (d1 - y0))  \

     114:                 + (self.data[i1 * self.r + j1] * (d0 - x0) * (d1 - y0))

        /* "bilinear.pyx":114
     *                 + (self.data[i1 * self.r + j0] * (d0 - x0) * (y1 - d1))  \
     *                 + (self.data[i0 * self.r + j1] * (x1 - d0) * (d1 - y0))  \
     *                 + (self.data[i1 * self.r + j1] * (d0 - x0) * (d1 - y0))             # <<<<<<<<<<<<<<
     *         return - res
     */
        __pyx_v_res = ((((((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i0 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j0)]) * (__pyx_v_x1 - __pyx_v_d0)) * (__pyx_v_y1 - __pyx_v_d1)) + (((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i1 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j0)]) * (__pyx_v_d0 - __pyx_v_x0)) * (__pyx_v_y1 - __pyx_v_d1))) + (((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i0 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j1)]) * (__pyx_v_x1 - __pyx_v_d0)) * (__pyx_v_d1 - __pyx_v_y0))) + (((((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->data[((__pyx_v_i1 * ((struct __pyx_obj_8bilinear_bilinear *)__pyx_v_self)->r) + __pyx_v_j1)]) * (__pyx_v_d0 - __pyx_v_x0)) * (__pyx_v_d1 - __pyx_v_y0)));
      }
      __pyx_L5:;

     115:         return - res

      /* "bilinear.pyx":115
     *                 + (self.data[i0 * self.r + j1] * (x1 - d0) * (d1 - y0))  \
     *                 + (self.data[i1 * self.r + j1] * (d0 - x0) * (d1 - y0))
     *         return - res             # <<<<<<<<<<<<<<
     */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = PyFloat_FromDouble((-__pyx_v_res)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("bilinear.bilinear.f_cy", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }