Changeset 2d06beb in sasview for pr_inversion/c_extensions
- Timestamp:
- May 5, 2008 2:03:39 PM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b43a009
- Parents:
- 150c04a
- Location:
- pr_inversion/c_extensions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pr_inversion/c_extensions/Cinvertor.c
reca05c8 r2d06beb 80 80 Py_ssize_t ndata; 81 81 double *data; 82 int i; 82 83 83 84 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 84 85 OUTVECTOR(data_obj,data,ndata); 85 self->params.x = data; 86 87 free(self->params.x); 88 self->params.x = (double*) malloc(ndata*sizeof(double)); 89 90 if(self->params.x==NULL) { 91 PyErr_SetString(CinvertorError, 92 "Cinvertor.set_x: problem allocating memory."); 93 return NULL; 94 } 95 96 for (i=0; i<ndata; i++) { 97 self->params.x[i] = data[i]; 98 } 99 100 //self->params.x = data; 86 101 self->params.npoints = ndata; 87 102 return Py_BuildValue("i", self->params.npoints); … … 95 110 96 111 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 97 INVECTOR(data_obj, data, ndata);112 OUTVECTOR(data_obj, data, ndata); 98 113 99 114 // Check that the input array is large enough … … 120 135 Py_ssize_t ndata; 121 136 double *data; 137 int i; 122 138 123 139 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 124 140 OUTVECTOR(data_obj,data,ndata); 125 self->params.y = data; 141 142 free(self->params.y); 143 self->params.y = (double*) malloc(ndata*sizeof(double)); 144 145 if(self->params.y==NULL) { 146 PyErr_SetString(CinvertorError, 147 "Cinvertor.set_y: problem allocating memory."); 148 return NULL; 149 } 150 151 for (i=0; i<ndata; i++) { 152 self->params.y[i] = data[i]; 153 } 154 155 //self->params.y = data; 126 156 self->params.ny = ndata; 127 157 return Py_BuildValue("i", self->params.ny); … … 135 165 136 166 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 137 INVECTOR(data_obj, data, ndata);167 OUTVECTOR(data_obj, data, ndata); 138 168 139 169 // Check that the input array is large enough … … 160 190 Py_ssize_t ndata; 161 191 double *data; 192 int i; 162 193 163 194 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 164 195 OUTVECTOR(data_obj,data,ndata); 165 self->params.err = data; 196 197 free(self->params.err); 198 self->params.err = (double*) malloc(ndata*sizeof(double)); 199 200 if(self->params.err==NULL) { 201 PyErr_SetString(CinvertorError, 202 "Cinvertor.set_err: problem allocating memory."); 203 return NULL; 204 } 205 206 for (i=0; i<ndata; i++) { 207 self->params.err[i] = data[i]; 208 } 209 210 //self->params.err = data; 166 211 self->params.nerr = ndata; 167 212 return Py_BuildValue("i", self->params.nerr); … … 175 220 176 221 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 177 INVECTOR(data_obj, data, ndata);222 OUTVECTOR(data_obj, data, ndata); 178 223 179 224 // Check that the input array is large enough … … 414 459 } 415 460 461 static PyObject * basefunc_ft(Cinvertor *self, PyObject *args) { 462 double d_max, q; 463 int n; 464 465 if (!PyArg_ParseTuple(args, "did", &d_max, &n, &q)) return NULL; 466 return Py_BuildValue("f", ortho_transformed(d_max, n, q)); 467 468 } 416 469 417 470 static PyMethodDef Cinvertor_methods[] = { … … 435 488 {"get_pr_err", (PyCFunction)get_pr_err, METH_VARARGS, ""}, 436 489 {"is_valid", (PyCFunction)is_valid, METH_VARARGS, ""}, 490 {"basefunc_ft", (PyCFunction)basefunc_ft, METH_VARARGS, ""}, 437 491 438 492 {NULL} -
pr_inversion/c_extensions/invertor.c
reca05c8 r2d06beb 8 8 */ 9 9 void invertor_dealloc(Invertor_params *pars) { 10 //free(pars->x);11 //free(pars->y);12 //free(pars->err);10 free(pars->x); 11 free(pars->y); 12 free(pars->err); 13 13 } 14 14 … … 133 133 } 134 134 135 -
pr_inversion/c_extensions/invertor.h
reca05c8 r2d06beb 29 29 void pr_err(double *pars, double *err, double d_max, int n_c, 30 30 double r, double *pr_value, double *pr_value_err); 31 32 31 #endif
Note: See TracChangeset
for help on using the changeset viewer.