int p4_pix2deltas( const unsigned int naxes, const distortion_lookup_t **lookup, /* [NAXES] */ const unsigned int nelem, const double* pix, /* [NAXES][nelem] */ double *foc /* [NAXES][nelem] */) { int i; double* foc0; const double* pix0; const double* pixend; assert(naxes == NAXES); assert(lookup != NULL); assert(pix != NULL); assert(foc != NULL); #ifndef NDEBUG unsigned int k; for (k = 0; k < naxes; ++k) { if (lookup[k] != NULL) { assert(lookup[k]->data != NULL); } } #endif if (pix == NULL || foc == NULL) { return 1; } pixend = pix + nelem * NAXES; /* This can't be parallelized, because pix may be equal to foc */ /* For the same reason, i needs to be in the inner loop */ for (pix0 = pix, foc0 = foc; pix0 < pixend; pix0 += NAXES, foc0 += NAXES) { for (i = 0; i < NAXES; ++i) { if (lookup[i]) { foc0[i] += get_distortion_offset(lookup[i], pix0); } } } return 0; }
/*@null@*/ static PyObject* PyDistLookup_get_offset( PyDistLookup* self, PyObject* args, /*@unused@*/ PyObject* kwds) { double coord[NAXES]; double result; if (self->x.data == NULL) { PyErr_SetString(PyExc_RuntimeError, "No data has been set for the lookup table"); return NULL; } if (!PyArg_ParseTuple(args, "dd:get_offset", &coord[0], &coord[1])) { return NULL; } result = get_distortion_offset(&self->x, coord); return PyFloat_FromDouble(result); }