Changeset f78a2a1 in sasmodels


Ignore:
Timestamp:
Mar 20, 2016 12:31:48 PM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

do volume weighting in new kernel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_iq.c

    rf9245d4 rf78a2a1  
    9797    NPARS = 4  // scale and background are in all models 
    9898    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 
    103104        par_offset = {2, 3, 303, 313}  // parameter offsets 
    104105        par_coord = {0, 3, 2, 1} // bitmap of parameter dependencies 
     
    207208    int pd_offset[MAX_PD];  // offset of pd weights in the par & weight vector 
    208209    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 
    209211    int par_offset[NPARS];  // offset of par values in the par & weight vector 
    210212    int par_coord[NPARS];   // polydispersity coordination bitvector 
     
    295297  // weights from the outer loops so that weight = partial_weight * fast_weight 
    296298  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 
    297302 
    298303  // Loop over the weights then loop over q, accumulating values 
     
    302307      pd_index[0] = loop_index%pd_length[0]; 
    303308      partial_weight = 1.0; 
     309      partial_volweight = 1.0; 
    304310      for (int k=1; k < MAX_PD; k++) { 
    305311        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; 
    307315      } 
    308316      weight = partial_weight * weights[pd_offset[0]+pd_index[0]] 
     
    323331    } else { 
    324332      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; 
    326336      for (int k=0; k < problem->fast_coord_count; k++) { 
    327337        parvec[ fast_coord_index[k]] 
     
    333343    #endif 
    334344    if (weight > cutoff) { 
    335       const double vol_weight = VOLUME_WEIGHT_PRODUCT; 
    336       const double weighted_vol = vol_weight*form_volume(VOLUME_PARAMETERS); 
    337345      norm += weight; 
    338       vol += weighted_vol; 
     346      vol += vol_weight * form_volume(VOLUME_PARAMETERS); 
    339347      norm_vol += vol_weight; 
    340348 
Note: See TracChangeset for help on using the changeset viewer.