Ignore:
Timestamp:
Jan 19, 2011 6:00:50 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
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:
a0da535
Parents:
12c5b87
Message:

fixed a bug on dispersion for non-integer nsigmas

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_models/parameters.cpp

    r0fff338f r1d78e4b  
    6363        } else { 
    6464                for(int i=0; i<npts; i++) { 
    65                         double val = value + width * (1.0*i/float(npts-1) - 0.5); 
     65                        double val = value + width * (1.0*double(i)/double(npts-1) - 0.5); 
    6666 
    6767                        if ( ((*par).has_min==false || val>(*par).min) 
     
    8585        npts  = 21; 
    8686        width = 0.0; 
    87         nsigmas = 3; 
     87        nsigmas = 3.0; 
    8888}; 
    8989 
     
    115115                width = 0.0; 
    116116                npts  = 1; 
    117                 nsigmas = 3; 
     117                nsigmas = 3.0; 
    118118        } 
    119119 
     
    126126                for(int i=0; i<npts; i++) { 
    127127                        // We cover n(nsigmas) times sigmas on each side of the mean 
    128                         double val = value + width * (2.0*nsigmas*i/float(npts-1) - nsigmas); 
    129  
     128                        double val = value + width * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas); 
    130129                        if ( ((*par).has_min==false || val>(*par).min) 
    131130                          && ((*par).has_max==false || val<(*par).max)  ) { 
     
    145144        npts  = 21; 
    146145        width = 0.0; 
    147         nsigmas = 3; 
     146        nsigmas = 3.0; 
    148147}; 
    149148 
     
    157156double lognormal_weight(double mean, double sigma, double x) { 
    158157 
    159         double sigma2 = pow(sigma, 2); 
    160         return 1/(x*sigma2) * exp( -pow((log(x) -mean), 2) / (2*sigma2)); 
     158        double sigma2 = pow(sigma, 2.0); 
     159        return 1.0/(x*sigma2) * exp( -pow((log(x) -mean), 2.0) / (2.0*sigma2)); 
    161160 
    162161} 
     
    174173                width = 0.0; 
    175174                npts  = 1; 
    176                 nsigmas = 3; 
     175                nsigmas = 3.0; 
    177176        } 
    178177 
     
    185184                for(int i=0; i<npts; i++) { 
    186185                        // We cover n(nsigmas) times sigmas on each side of the mean 
    187                         double val = value + width * (2.0*nsigmas*i/float(npts-1) - nsigmas); 
     186                        double val = value + width * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas); 
    188187 
    189188                        if ( ((*par).has_min==false || val>(*par).min) 
     
    205204        npts  = 21; 
    206205        width = 0.0; 
    207         nsigmas = 3; 
     206        nsigmas = 3.0; 
    208207}; 
    209208 
     
    217216double schulz_weight(double mean, double sigma, double x) { 
    218217        double vary, expo_value; 
    219     double z = pow(mean/ sigma, 2)-1; 
     218    double z = pow(mean/ sigma, 2.0)-1.0; 
    220219        double R= x/mean; 
    221         double zz= z+1; 
     220        double zz= z+1.0; 
    222221        double expo; 
    223222        expo = zz*log(zz)+z*log(R)-R*zz-log(mean)-lgamma(zz); 
     
    237236                width = 0.0; 
    238237                npts  = 1; 
    239                 nsigmas = 3; 
     238                nsigmas = 3.0; 
    240239        } 
    241240 
     
    248247                for(int i=0; i<npts; i++) { 
    249248                        // We cover n(nsigmas) times sigmas on each side of the mean 
    250                         double val = value + width * (2.0*nsigmas*i/float(npts-1) - nsigmas); 
     249                        double val = value + width * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas); 
    251250 
    252251                        if ( ((*par).has_min==false || val>(*par).min) 
Note: See TracChangeset for help on using the changeset viewer.