Changeset 8dc02d8b in sasview for sansmodels/src/sans/models/c_models/parameters.cpp
- Timestamp:
- Jan 20, 2011 2:10:08 PM (13 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:
- 75df58b
- Parents:
- 943cacb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/parameters.cpp
r1d78e4b r8dc02d8b 98 98 double vary, expo_value; 99 99 vary = x-mean; 100 expo_value = -vary*vary/(2 *sigma*sigma);100 expo_value = -vary*vary/(2.0*sigma*sigma); 101 101 //return 1.0; 102 102 return exp(expo_value); … … 130 130 && ((*par).has_max==false || val<(*par).max) ) { 131 131 double _w = gaussian_weight(value, width, val); 132 weights.insert(weights.end(), WeightPoint(val, _w)); 133 } 134 } 135 } 136 } 137 138 139 /** 140 * Flat dispersion 141 */ 142 143 RectangleDispersion :: RectangleDispersion() { 144 npts = 21; 145 width = 0.0; 146 nsigmas = 1.0; 147 }; 148 149 void RectangleDispersion :: accept_as_source(DispersionVisitor* visitor, void* from, void* to) { 150 visitor->rectangle_to_dict(from, to); 151 } 152 void RectangleDispersion :: accept_as_destination(DispersionVisitor* visitor, void* from, void* to) { 153 visitor->rectangle_from_dict(from, to); 154 } 155 156 double rectangle_weight(double mean, double sigma, double x) { 157 double vary, expo_value; 158 double sig = fabs(sigma); 159 if (x>= (mean-sig) && x<(mean+sig)){ 160 return 1.0; 161 } 162 else{ 163 return 0.0; 164 } 165 } 166 167 /** 168 * Flat dispersion 169 * @param mean: mean value 170 * @param sigma: half width of top hat function 171 * @param x: value at which the Flat is evaluated 172 * @return: value of the Flat 173 */ 174 void RectangleDispersion :: operator() (void *param, vector<WeightPoint> &weights){ 175 // Check against zero width 176 if (width<=0) { 177 width = 0.0; 178 npts = 1; 179 nsigmas = 1.0; 180 } 181 182 Parameter* par = (Parameter*)param; 183 double value = (*par)(); 184 185 if (npts<2) { 186 weights.insert(weights.end(), WeightPoint(value, 1.0)); 187 } else { 188 for(int i=0; i<npts; i++) { 189 // We cover n(nsigmas) times sigmas on each side of the mean 190 double val = value + width * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas); 191 if ( ((*par).has_min==false || val>(*par).min) 192 && ((*par).has_max==false || val<(*par).max) ) { 193 double _w = rectangle_weight(value, width, val); 132 194 weights.insert(weights.end(), WeightPoint(val, _w)); 133 195 }
Note: See TracChangeset
for help on using the changeset viewer.