Changeset f78a2a1 in sasmodels
- Timestamp:
- Mar 20, 2016 12:31:48 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- f35f1dd
- Parents:
- f9245d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_iq.c
rf9245d4 rf78a2a1 97 97 NPARS = 4 // scale and background are in all models 98 98 problem { 99 pd_par = {5, 4, x, x} // parameters *radius* and *length* vary 100 pd_length = {30,10,0,0} // *length* has more, so it is first 101 pd_offset = {10,0,x,x} // *length* starts at index 10 in weights 102 pd_stride = {1,30,300,300} // cumulative product of pd length 99 pd_par = {5, 4, x, x} // parameters *radius* and *length* vary 100 pd_length = {30, 10, 0, 0} // *length* has more, so it is first 101 pd_offset = {10, 0, x, x} // *length* starts at index 10 in weights 102 pd_stride = {1, 30, 300, 300} // cumulative product of pd length 103 pd_isvol = {1, 1, x, x} // true if weight is a volume weight 103 104 par_offset = {2, 3, 303, 313} // parameter offsets 104 105 par_coord = {0, 3, 2, 1} // bitmap of parameter dependencies … … 207 208 int pd_offset[MAX_PD]; // offset of pd weights in the par & weight vector 208 209 int pd_stride[MAX_PD]; // stride to move to the next index at this level 210 int pd_isvol[MAX_PD]; // True if parameter is a volume weighting parameter 209 211 int par_offset[NPARS]; // offset of par values in the par & weight vector 210 212 int par_coord[NPARS]; // polydispersity coordination bitvector … … 295 297 // weights from the outer loops so that weight = partial_weight * fast_weight 296 298 double partial_weight = NAN; // product of weight w4*w3*w2 but not w1 299 double partial_volweight = NAN; 300 double weight = 1.0; // set to 1 in case there are no weights 301 double vol_weight = 1.0; // set to 1 in case there are no vol weights 297 302 298 303 // Loop over the weights then loop over q, accumulating values … … 302 307 pd_index[0] = loop_index%pd_length[0]; 303 308 partial_weight = 1.0; 309 partial_volweight = 1.0; 304 310 for (int k=1; k < MAX_PD; k++) { 305 311 pd_index[k] = (loop_index%pd_length[k])/pd_stride[k]; 306 partial_weight *= weights[pd_offset[k]+pd_index[k]]; 312 const double wi = weights[pd_offset[0]+pd_index[0]]; 313 partial_weight *= wi; 314 if (pd_isvol[k]) partial_volweight *= wi; 307 315 } 308 316 weight = partial_weight * weights[pd_offset[0]+pd_index[0]] … … 323 331 } else { 324 332 pd_index[0] += 1; 325 weight = partial_weight*weights[pd_offset[0]+pd_index[0]]; 333 const double wi = weights[pd_offset[0]+pd_index[0]]; 334 weight = partial_weight*wi; 335 if (pd_isvol[0]) vol_weight *= wi; 326 336 for (int k=0; k < problem->fast_coord_count; k++) { 327 337 parvec[ fast_coord_index[k]] … … 333 343 #endif 334 344 if (weight > cutoff) { 335 const double vol_weight = VOLUME_WEIGHT_PRODUCT;336 const double weighted_vol = vol_weight*form_volume(VOLUME_PARAMETERS);337 345 norm += weight; 338 vol += weighted_vol;346 vol += vol_weight * form_volume(VOLUME_PARAMETERS); 339 347 norm_vol += vol_weight; 340 348
Note: See TracChangeset
for help on using the changeset viewer.