Changeset 7678 for trunk/projects/slimcurve/src
 Timestamp:
 04/01/11 20:00:35 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/projects/slimcurve/src/main/c/EcfWrapper.c
r7387 r7678 22 22 int noise = 0; 23 23 int n_data = fit_end + 1; 24 25 24 float *y_float = (float *)malloc(n_data * sizeof(float)); 26 25 float *sig_float = (float *)malloc(n_data * sizeof(float)); 27 int i;28 for (i = 0; i < n_data; ++i) {29 y_float[i] = (float) y[i];30 sig_float[i] = ( sig ? (float) sig[i] : 1.0f );31 }32 33 26 float *instr_float = 0; 34 if (instr) {35 instr_float = (float *)malloc(n_instr * sizeof(float));36 int i;37 for (i = 0; i < n_instr; ++i) {38 instr_float[i] = (float) instr[i];39 }40 }41 27 float *fitted_float = 0; 42 if (fitted) {43 fitted_float = (float*)malloc(n_data * sizeof(float));44 }45 28 float *residuals_float = (float *)malloc(n_data * sizeof(float)); 46 47 29 float x_inc_float = (float) x_inc; 48 30 float z_float = (float) *z; … … 50 32 float tau_float = (float) *tau; 51 33 float chi_square_float = (float) *chi_square; 52 53 int returnValue = GCI_triple_integral_fitting_engine( 34 int return_value; 35 int i; 36 37 for (i = 0; i < n_data; ++i) { 38 y_float[i] = (float) y[i]; 39 sig_float[i] = ( sig ? (float) sig[i] : 1.0f ); 40 } 41 42 if (instr) { 43 int i; 44 instr_float = (float *)malloc(n_instr * sizeof(float)); 45 for (i = 0; i < n_instr; ++i) { 46 instr_float[i] = (float) instr[i]; 47 } 48 } 49 50 if (fitted) { 51 fitted_float = (float*)malloc(n_data * sizeof(float)); 52 } 53 54 return_value = GCI_triple_integral_fitting_engine( 54 55 x_inc_float, 55 56 y_float, … … 89 90 free(residuals_float); 90 91 91 return return Value;92 return return_value; 92 93 } 93 94 … … 113 114 float chi_square_percent = 500; 114 115 int n_data = fit_end + 1; 115 116 116 float *y_float = (float *)malloc(n_data * sizeof(float)); 117 117 float *sig_float = (float *)malloc(n_data * sizeof(float)); 118 float *instr_float = 0; 119 float *fitted_float = 0; 120 float *param_float; 121 float *residuals_float = (float *)malloc(n_data * sizeof(float)); 122 float **covar_float = GCI_ecf_matrix(n_data, n_data); 123 float **alpha_float = GCI_ecf_matrix(n_data, n_data); 124 float **err_axes_float = GCI_ecf_matrix(n_data, n_data); 125 float x_inc_float = (float) x_inc; 126 float chi_square_float = (float) *chi_square; 127 void (*fitfunc)(float, float [], float *, float[], int) = NULL; 128 int return_value; 118 129 int i; 130 119 131 for (i = 0; i < n_data; ++i) { 120 132 y_float[i] = (float) y[i]; … … 122 134 } 123 135 124 float *instr_float = 0;125 136 if (instr) { 137 int i; 126 138 instr_float = (float *)malloc(n_instr * sizeof(float)); 127 int i;128 139 for (i = 0; i < n_instr; ++i) { 129 140 instr_float[i] = (float) instr[i]; 130 141 } 131 142 } 132 float *fitted_float = 0; 143 133 144 if (fitted) { 134 145 fitted_float = (float*)malloc(n_data * sizeof(float)); 135 146 } 136 float *param_float = (float *)malloc(n_param * sizeof(float));147 param_float = (float *)malloc(n_param * sizeof(float)); 137 148 switch (n_param) { 138 149 case 3: … … 171 182 } 172 183 173 float *residuals_float = (float *)malloc(n_data * sizeof(float));174 float **covar_float = GCI_ecf_matrix(n_data, n_data);175 float **alpha_float = GCI_ecf_matrix(n_data, n_data);176 float **err_axes_float = GCI_ecf_matrix(n_data, n_data);177 178 float x_inc_float = (float) x_inc;179 float chi_square_float = (float) *chi_square;180 181 184 // choose appropriate fitting function 182 void (*fitfunc)(float, float [], float *, float[], int) = NULL;183 185 if (4 == n_param) { 184 186 fitfunc = GCI_stretchedexp; … … 188 190 } 189 191 190 int returnValue = GCI_marquardt_fitting_engine(192 return_value = GCI_marquardt_fitting_engine( 191 193 x_inc_float, //TODO not necessary, just cast it, I think 192 194 y_float, … … 276 278 //} 277 279 278 return return Value;280 return return_value; 279 281 } 280 282
Note: See TracChangeset
for help on using the changeset viewer.