Changeset 6e7ff6d in sasmodels for sasmodels/kernel_iq.c


Ignore:
Timestamp:
Apr 7, 2016 2:01:54 PM (8 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:
3543141
Parents:
8bd7b77
Message:

reenable python models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_iq.c

    r398aa94 r6e7ff6d  
    4242    const int32_t pd_start,     // where we are in the polydispersity loop 
    4343    const int32_t pd_stop,      // where we are stopping in the polydispersity loop 
    44     global const ProblemDetails *problem, 
     44    global const ProblemDetails *details, 
    4545    global const double *weights, 
    4646    global const double *values, 
     
    6060  #endif 
    6161  for (int k=0; k < NPARS; k++) { 
    62     pvec[k] = values[problem->par_offset[k]]; 
     62    pvec[k] = values[details->par_offset[k]]; 
    6363  } 
    6464 
     
    7878 
    7979  // Monodisperse computation 
    80   if (problem->num_active == 0) { 
     80  if (details->num_active == 0) { 
    8181    #ifdef INVALID 
    8282    if (INVALID(local_values)) { return; } 
     
    116116  // Trigger the reset behaviour that happens at the end the fast loop 
    117117  // by setting the initial index >= weight vector length. 
    118   const int fast_length = problem->pd_length[0]; 
     118  const int fast_length = details->pd_length[0]; 
    119119  pd_index[0] = fast_length; 
    120120 
     
    123123    // check if indices need to be updated 
    124124    if (pd_index[0] == fast_length) { 
    125       //printf("should be here with %d active\n", problem->num_active); 
     125      //printf("should be here with %d active\n", details->num_active); 
    126126 
    127127      // Compute position in polydispersity hypercube 
    128       for (int k=0; k < problem->num_active; k++) { 
    129         pd_index[k] = (loop_index/problem->pd_stride[k])%problem->pd_length[k]; 
     128      for (int k=0; k < details->num_active; k++) { 
     129        pd_index[k] = (loop_index/details->pd_stride[k])%details->pd_length[k]; 
    130130        //printf("pd_index[%d] = %d\n",k,pd_index[k]); 
    131131      } 
     
    134134      partial_weight = 1.0; 
    135135      //printf("partial weight %d: ", loop_index); 
    136       for (int k=1; k < problem->num_active; k++) { 
    137         double wi = weights[problem->pd_offset[k] + pd_index[k]]; 
    138         //printf("pd[%d]=par[%d]=%g ", k, problem->pd_par[k], wi); 
     136      for (int k=1; k < details->num_active; k++) { 
     137        double wi = weights[details->pd_offset[k] + pd_index[k]]; 
     138        //printf("pd[%d]=par[%d]=%g ", k, details->pd_par[k], wi); 
    139139        partial_weight *= wi; 
    140140      } 
     
    143143      // Update parameter offsets in weight vector 
    144144      //printf("slow %d: ", loop_index); 
    145       for (int k=0; k < problem->num_coord; k++) { 
    146         int par = problem->par_coord[k]; 
    147         int coord = problem->pd_coord[k]; 
    148         int this_offset = problem->par_offset[par]; 
     145      for (int k=0; k < details->num_coord; k++) { 
     146        int par = details->par_coord[k]; 
     147        int coord = details->pd_coord[k]; 
     148        int this_offset = details->par_offset[par]; 
    149149        int block_size = 1; 
    150150        for (int bit=0; coord != 0; bit++) { 
    151151          if (coord&1) { 
    152152              this_offset += block_size * pd_index[bit]; 
    153               block_size *= problem->pd_length[bit]; 
     153              block_size *= details->pd_length[bit]; 
    154154          } 
    155155          coord >>= 1; 
     
    159159        //printf("par[%d]=v[%d]=%g \n", k, offset[k], pvec[k]); 
    160160        // if theta is not coordinated with fast index, precompute spherical correction 
    161         if (par == problem->theta_par && !(problem->par_coord[k]&1)) { 
    162           spherical_correction = fmax(fabs(cos(M_PI_180*pvec[problem->theta_par])), 1e-6); 
     161        if (par == details->theta_par && !(details->par_coord[k]&1)) { 
     162          spherical_correction = fmax(fabs(cos(M_PI_180*pvec[details->theta_par])), 1e-6); 
    163163        } 
    164164      } 
     
    167167 
    168168    // Increment fast index 
    169     const double wi = weights[problem->pd_offset[0] + pd_index[0]++]; 
     169    const double wi = weights[details->pd_offset[0] + pd_index[0]++]; 
    170170    double weight = partial_weight*wi; 
    171171    //printf("fast %d: ", loop_index); 
    172     for (int k=0; k < problem->num_coord; k++) { 
    173       if (problem->pd_coord[k]&1) { 
    174         const int par = problem->par_coord[k]; 
     172    for (int k=0; k < details->num_coord; k++) { 
     173      if (details->pd_coord[k]&1) { 
     174        const int par = details->par_coord[k]; 
    175175        pvec[par] = values[offset[par]++]; 
    176176        //printf("p[%d]=v[%d]=%g ", par, offset[par]-1, pvec[par]); 
    177177        // if theta is coordinated with fast index, compute spherical correction each time 
    178         if (par == problem->theta_par) { 
    179           spherical_correction = fmax(fabs(cos(M_PI_180*pvec[problem->theta_par])), 1e-6); 
     178        if (par == details->theta_par) { 
     179          spherical_correction = fmax(fabs(cos(M_PI_180*pvec[details->theta_par])), 1e-6); 
    180180        } 
    181181      } 
     
    209209 
    210210  // End of the PD loop we can normalize 
    211   if (pd_stop >= problem->total_pd) { 
     211  if (pd_stop >= details->total_pd) { 
    212212    const double scale = values[0]; 
    213213    const double background = values[1]; 
     
    216216    #endif 
    217217    for (int i=0; i < nq; i++) { 
    218       result[i] = (norm>0. ? scale*scattering/norm + background : background); 
     218      result[i] = (norm>0. ? scale*result[i]/norm + background : background); 
    219219    } 
    220220  } 
Note: See TracChangeset for help on using the changeset viewer.