Changeset 7675
 Timestamp:
 03/25/11 20:25:53 (9 years ago)
 Location:
 trunk/projects/slimcurve/src/main/c
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/projects/slimcurve/src/main/c/EcfGlobal.c
r7611 r7675 3245 3245 //// yfit[i], dy[i], alpha_scratch, beta_scratch, 3246 3246 yfit[0], dy[0], alpha_scratch, beta_scratch, 3247 &chisq_trans[i], (i == 0) ? alambda : 0.0,3247 &chisq_trans[i], 0.0f, (i == 0) ? alambda : 0.0, //TODO ARG added 0.0f here for new old_chisq parameter 3248 3248 pfnvals, pdy_dparam_pure, pdy_dparam_conv, 3249 3249 pfnvals_len, pdy_dparam_nparam_size); 
trunk/projects/slimcurve/src/main/c/EcfInternal.h
r7387 r7675 33 33 void (*fitfunc)(float, float [], float *, float [], int), 34 34 float yfit[], float dy[], 35 float **alpha, float beta[], float *chisq, 35 float **alpha, float beta[], float *chisq, float old_chisq, 36 36 float alambda, 37 37 float **pfnvals, float ***pdy_dparam_pure, float ***pdy_dparam_conv, 
trunk/projects/slimcurve/src/main/c/EcfSingle.c
r7606 r7675 27 27 28 28 /* Globals */ 29 static float global_chisq = 0.0f;30 29 //static float *fnvals, **dy_dparam_pure, **dy_dparam_conv; 31 30 //static int fnvals_len=0, dy_dparam_nparam_size=0; … … 654 653 if (paramfree[j]) 655 654 (*pmfit)++; 656 global_chisq = 0.0f; 655 657 656 if (GCI_marquardt_compute_fn_instr(xincr, y, ndata, fit_start, fit_end, 658 657 instr, ninstr, noise, sig, 659 658 param, paramfree, nparam, fitfunc, 660 yfit, dy, alpha, beta, chisq, 659 yfit, dy, alpha, beta, chisq, 0.0, 661 660 *alambda, 662 661 pfnvals, pdy_dparam_pure, pdy_dparam_conv, … … 705 704 } 706 705 707 /* Did the trial succeed? */ 706 /* Did the trial succeed? * 707 int allzeroes = 1; 708 708 for (j=0, l=0; l<nparam; l++) 709 if (paramfree[l]) 709 if (paramfree[l]) { 710 //TODO I don't think it ever recovers if all dparams are zero; alambda grows and grows, goes from int to inf!! 711 // could be an early way to detect we're done. 712 // at least, if delta params is all zeroes, there is no point in calculating a new alpha and beta. 713 // printf("paramtry[%d] was %f becomes %f, param[%d] or %f plus dparam[%d] or %f\n", l, paramtry[l], param[l] + dparam[j], l, param[l], j, dparam[j]); 714 if (dparam[j] != 0.0) allzeroes = 0; 710 715 paramtry[l] = param[l] + dparam[j++]; 716 } 717 //TODO experimental: 718 // gave about a 10% speedup 719 if (allzeroes) return 12345; */ 711 720 712 721 if (restrain == ECF_RESTRAIN_DEFAULT) … … 720 729 return 0; 721 730 } 722 global_chisq = *pochisq; //TODO this is a cheap mechanism to "pass in" the original chisq by using a global variable; seems to be a valid optimization, within this function don't setup matrices if chisq is not an improvment723 731 if (GCI_marquardt_compute_fn_instr(xincr, y, ndata, fit_start, fit_end, 724 732 instr, ninstr, noise, sig, 725 733 paramtry, paramfree, nparam, fitfunc, 726 734 yfit, dy, covar, dparam, 727 chisq, * alambda,735 chisq, *pochisq, *alambda, 728 736 pfnvals, pdy_dparam_pure, pdy_dparam_conv, 729 737 pfnvals_len, pdy_dparam_nparam_size) != 0) { … … 733 741 /* Success, accept the new solution */ 734 742 if (*chisq < *pochisq) { 743 // printf("success, alambda goes from %f to %f\n", *alambda, (*alambda)*0.1); 735 744 *alambda *= 0.1; 736 745 *pochisq = *chisq; … … 743 752 param[l] = paramtry[l]; 744 753 } else { /* Failure, increase alambda and return */ 754 //TODO if alambda goes to inf, can we recover? 755 // printf("failure, alambda goes from %f to %f\n", *alambda, (*alambda)*10.0); 745 756 *alambda *= 10.0; 746 757 *chisq = *pochisq; … … 789 800 void (*fitfunc)(float, float [], float *, float [], int), 790 801 float yfit[], float dy[], 791 float **alpha, float beta[], float *chisq, 802 float **alpha, float beta[], float *chisq, float old_chisq, 792 803 float alambda, 793 804 float **pfnvals, float ***pdy_dparam_pure, float ***pdy_dparam_conv, … … 1042 1053 1043 1054 // Check if chi square worsened: 1044 if (0.0f != global_chisq && *chisq >= global_chisq) { //TODO pass in the old chi square as a parameter1055 if (0.0f != old_chisq && *chisq >= old_chisq) { 1045 1056 // don't bother to set up the matrices for solution 1046 1057 return 0; … … 1085 1096 ++i_free; 1086 1097 } 1098 //else printf("param not free %d\n", i); 1087 1099 } // i loop 1100 1101 /* printf("i_free is %d j_free %d\n", i_free, j_free); 1102 //TODO try padding with zeroes; leftovers would affect AX=B solution 1103 for (i = i_free; i < nparam; ++i) { 1104 for (j = 0; j < nparam; ++j) { 1105 alpha[i][j] = alpha[j][i] = 0.0f; 1106 } 1107 beta[i] = 0.0f; 1108 }*/ 1109 1088 1110 } 1089 1111 return 0;
Note: See TracChangeset
for help on using the changeset viewer.