Changeset 54b0650 in sasview for src/sas/sascalc/calculator/c_extensions/sld2i.c
- Timestamp:
- Nov 7, 2017 11:05:12 AM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f926abb
- Parents:
- 0957bb3a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/c_extensions/sld2i.c
r0957bb3a r54b0650 25 25 * @param s_theta: angle (from x-axis) of the up spin in degree 26 26 */ 27 void initGenI(GenI* this, int npix, double* x, double* y, double* z, double* sldn,27 void initGenI(GenI* this, int is_avg, int npix, double* x, double* y, double* z, double* sldn, 28 28 double* mx, double* my, double* mz, double* voli, 29 29 double in_spin, double out_spin, 30 30 double s_theta) { 31 this->is_avg = is_avg; 31 32 this->n_pix = npix; 32 33 this->x_val = x; … … 73 74 // Loop over q-values and multiply apply matrix 74 75 76 //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 75 77 for(int i=0; i<npoints; i++){ 76 78 //I_out[i] = 0.0; … … 150 152 // Assumes that q doesn't have qz component and sld_n is all real 151 153 //double Pi = 4.0*atan(1.0); 152 int is_sym = this->n_pix < 0;153 154 double qr = 0.0; 154 155 double sumj; 155 156 double sld_j = 0.0; 156 157 double count = 0.0; 157 int n_pix = is_sym ? -this->n_pix : this->n_pix;158 158 //Assume that pixel volumes are given in vol_pix in A^3 unit 159 159 // Loop over q-values and multiply apply matrix 160 160 for(int i=0; i<npoints; i++){ 161 161 sumj =0.0; 162 for(int j=0; j< n_pix; j++){162 for(int j=0; j<this->n_pix; j++){ 163 163 //Isotropic: Assumes all slds are real (no magnetic) 164 164 //Also assumes there is no polarization: No dependency on spin 165 if ( is_sym== 1){165 if (this->is_avg == 1){ 166 166 // approximation for a spherical symmetric particle 167 167 qr = sqrt(this->x_val[j]*this->x_val[j]+this->y_val[j]*this->y_val[j]+this->z_val[j]*this->z_val[j])*q[i]; … … 177 177 //full calculation 178 178 //pragma omp parallel for 179 for(int k=0; k< n_pix; k++){179 for(int k=0; k<this->n_pix; k++){ 180 180 sld_j = this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k]; 181 181 qr = (this->x_val[j]-this->x_val[k])*(this->x_val[j]-this->x_val[k])+ … … 196 196 } 197 197 I_out[i] = sumj; 198 if ( is_sym == 1){198 if (this->is_avg == 1) { 199 199 I_out[i] *= sumj; 200 200 }
Note: See TracChangeset
for help on using the changeset viewer.