Changeset 7803 for trunk/projects/slimcurve/src/main/c/GCI_Phasor.c
 Timestamp:
 11/08/11 10:47:14 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/projects/slimcurve/src/main/c/GCI_Phasor.c
r7781 r7803 20 20 #include "GCI_Phasor.h" 21 21 #include <math.h> 22 #include <string.h> 22 23 23 24 #ifndef NULL … … 67 68 68 69 // rep frequency, lets use the period of the measurement, but we can stay in the units of bins 69 w = 2.0*3.1415926535897932384626433832795028841971/(float)nBins; //2.0*PI/(float)nBins;70 w = (float)2.0*(float)3.1415926535897932384626433832795028841971/(float)nBins; //2.0*PI/(float)nBins; 70 71 71 72 // integral over data … … 76 77 // Take care that values correspond to the centre of the bin, hence i+0.5 77 78 for (i=0, u=0.0; i<nBins; i++) 78 u += (data[i]bg) * cos(w*((float)i+0.5));79 u += (data[i]bg) * (float)cos(w*((float)i+0.5)); 79 80 u /= I; 80 81 81 82 for (i=0, v=0.0; i<nBins; i++) 82 v += (data[i]bg) * sin(w*((float)i+0.5));83 v += (data[i]bg) * (float)sin(w*((float)i+0.5)); 83 84 v /= I; 84 85 85 86 // taus, convert now to real time with xincr 86 87 *taup = (xincr/w) * (v/u); 87 *taum = (xincr/w) * sqrt(1.0/(u*u + v*v)  1.0);88 *taum = (xincr/w) * (float)sqrt(1.0/(u*u + v*v)  1.0); 88 89 89 *tau = ((*taup) + (*taum))/ 2.0;90 *tau = ((*taup) + (*taum))/(float)2.0; 90 91 91 92 *U = u; … … 101 102 // integral over nominal fit data 102 103 for (Ifit=0.0, i=fit_start; i<fit_end; i++) 103 Ifit += exp((ifit_start)*xincr/(*tau));104 Ifit += (float)exp((ifit_start)*xincr/(*tau)); 104 105 105 106 // Estimate A … … 108 109 // Calculate fit 109 110 for (i=fit_start; i<fit_end; i++) 110 fitted[i] = bg + A * exp((ifit_start)*xincr/(*tau));111 fitted[i] = bg + A * (float)exp((ifit_start)*xincr/(*tau)); 111 112 112 113 // OK, so now fitted contains our data for the timeslice of interest. … … 132 133 residuals[i] = res; 133 134 /* don't let variance drop below 1 */ 134 sigma2 = (fitted[i] > 1 ? 1.0/fitted[i] :1.0);135 sigma2 = (fitted[i] > 1 ? (float)1.0/fitted[i] : (float)1.0); 135 136 chisq_local += res * res * sigma2; 136 137 }
Note: See TracChangeset
for help on using the changeset viewer.