Changeset 6e7ff6d in sasmodels for sasmodels/kernel_iq.c
- Timestamp:
- Apr 7, 2016 2:01:54 PM (8 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:
- 3543141
- Parents:
- 8bd7b77
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_iq.c
r398aa94 r6e7ff6d 42 42 const int32_t pd_start, // where we are in the polydispersity loop 43 43 const int32_t pd_stop, // where we are stopping in the polydispersity loop 44 global const ProblemDetails * problem,44 global const ProblemDetails *details, 45 45 global const double *weights, 46 46 global const double *values, … … 60 60 #endif 61 61 for (int k=0; k < NPARS; k++) { 62 pvec[k] = values[ problem->par_offset[k]];62 pvec[k] = values[details->par_offset[k]]; 63 63 } 64 64 … … 78 78 79 79 // Monodisperse computation 80 if ( problem->num_active == 0) {80 if (details->num_active == 0) { 81 81 #ifdef INVALID 82 82 if (INVALID(local_values)) { return; } … … 116 116 // Trigger the reset behaviour that happens at the end the fast loop 117 117 // 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]; 119 119 pd_index[0] = fast_length; 120 120 … … 123 123 // check if indices need to be updated 124 124 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); 126 126 127 127 // 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]; 130 130 //printf("pd_index[%d] = %d\n",k,pd_index[k]); 131 131 } … … 134 134 partial_weight = 1.0; 135 135 //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); 139 139 partial_weight *= wi; 140 140 } … … 143 143 // Update parameter offsets in weight vector 144 144 //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]; 149 149 int block_size = 1; 150 150 for (int bit=0; coord != 0; bit++) { 151 151 if (coord&1) { 152 152 this_offset += block_size * pd_index[bit]; 153 block_size *= problem->pd_length[bit];153 block_size *= details->pd_length[bit]; 154 154 } 155 155 coord >>= 1; … … 159 159 //printf("par[%d]=v[%d]=%g \n", k, offset[k], pvec[k]); 160 160 // 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); 163 163 } 164 164 } … … 167 167 168 168 // 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]++]; 170 170 double weight = partial_weight*wi; 171 171 //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]; 175 175 pvec[par] = values[offset[par]++]; 176 176 //printf("p[%d]=v[%d]=%g ", par, offset[par]-1, pvec[par]); 177 177 // 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); 180 180 } 181 181 } … … 209 209 210 210 // End of the PD loop we can normalize 211 if (pd_stop >= problem->total_pd) {211 if (pd_stop >= details->total_pd) { 212 212 const double scale = values[0]; 213 213 const double background = values[1]; … … 216 216 #endif 217 217 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); 219 219 } 220 220 }
Note: See TracChangeset
for help on using the changeset viewer.