Changeset 4f63160 in sasview for pr_inversion/c_extensions
- Timestamp:
- May 8, 2008 7:13:59 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:
- 32dffae4
- Parents:
- 34ab06d
- Location:
- pr_inversion/c_extensions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pr_inversion/c_extensions/Cinvertor.c
rabad620 r4f63160 484 484 norm = int_p2(pars, self->params.d_max, npars, 100); 485 485 return Py_BuildValue("f", sqrt(oscill/norm)/acos(-1.0)*self->params.d_max ); 486 487 } 488 489 static PyObject * get_peaks(Cinvertor *self, PyObject *args) { 490 double *pars; 491 PyObject *data_obj; 492 Py_ssize_t npars; 493 int count; 494 495 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 496 OUTVECTOR(data_obj,pars,npars); 497 498 count = npeaks(pars, self->params.d_max, npars, 100); 499 500 return Py_BuildValue("i", count ); 486 501 487 502 } … … 509 524 {"basefunc_ft", (PyCFunction)basefunc_ft, METH_VARARGS, ""}, 510 525 {"oscillations", (PyCFunction)oscillations, METH_VARARGS, ""}, 526 {"get_peaks", (PyCFunction)get_peaks, METH_VARARGS, ""}, 511 527 512 528 {NULL} -
pr_inversion/c_extensions/invertor.c
rabad620 r4f63160 152 152 } 153 153 154 /** 155 * Get the number of P(r) peaks. 156 */ 157 int npeaks(double *pars, double d_max, int n_c, int nslice) { 158 double r; 159 double value; 160 int i; 161 double previous = 0.0; 162 double slope = 0.0; 163 int count = 0; 164 for (i=0; i<nslice; i++) { 165 r = d_max/(1.0*nslice)*i; 166 value = pr(pars, d_max, n_c, r); 167 if (previous<=value){ 168 //if (slope<0) count += 1; 169 slope = 1; 170 } else { 171 //printf("slope -1"); 172 if (slope>0) count += 1; 173 slope = -1; 174 } 175 previous = value; 176 } 177 return count; 178 } 179 -
pr_inversion/c_extensions/invertor.h
rabad620 r4f63160 30 30 void pr_err(double *pars, double *err, double d_max, int n_c, 31 31 double r, double *pr_value, double *pr_value_err); 32 int npeaks(double *pars, double d_max, int n_c, int nslice); 33 32 34 #endif
Note: See TracChangeset
for help on using the changeset viewer.