Ignore:
Timestamp:
Nov 7, 2017 11:05:12 AM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

fix C interface to sldi after py3 conversion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/calculator/c_extensions/sld2i.c

    r0957bb3a r54b0650  
    2525 * @param s_theta: angle (from x-axis) of the up spin in degree 
    2626 */ 
    27 void initGenI(GenI* this, int npix, double* x, double* y, double* z, double* sldn, 
     27void initGenI(GenI* this, int is_avg, int npix, double* x, double* y, double* z, double* sldn, 
    2828                        double* mx, double* my, double* mz, double* voli, 
    2929                        double in_spin, double out_spin, 
    3030                        double s_theta) { 
     31        this->is_avg = is_avg; 
    3132        this->n_pix = npix; 
    3233        this->x_val = x; 
     
    7374        // Loop over q-values and multiply apply matrix 
    7475 
     76        //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 
    7577        for(int i=0; i<npoints; i++){ 
    7678                //I_out[i] = 0.0; 
     
    150152        // Assumes that q doesn't have qz component and sld_n is all real 
    151153        //double Pi = 4.0*atan(1.0); 
    152         int is_sym = this->n_pix < 0; 
    153154        double qr = 0.0; 
    154155        double sumj; 
    155156        double sld_j = 0.0; 
    156157        double count = 0.0; 
    157         int n_pix = is_sym ? -this->n_pix : this->n_pix; 
    158158        //Assume that pixel volumes are given in vol_pix in A^3 unit 
    159159        // Loop over q-values and multiply apply matrix 
    160160        for(int i=0; i<npoints; i++){ 
    161161                sumj =0.0; 
    162                 for(int j=0; j<n_pix; j++){ 
     162                for(int j=0; j<this->n_pix; j++){ 
    163163                        //Isotropic: Assumes all slds are real (no magnetic) 
    164164                        //Also assumes there is no polarization: No dependency on spin 
    165                         if (is_sym == 1){ 
     165                        if (this->is_avg == 1){ 
    166166                                // approximation for a spherical symmetric particle 
    167167                                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]; 
     
    177177                                //full calculation 
    178178                                //pragma omp parallel for 
    179                                 for(int k=0; k<n_pix; k++){ 
     179                                for(int k=0; k<this->n_pix; k++){ 
    180180                                        sld_j =  this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k]; 
    181181                                        qr = (this->x_val[j]-this->x_val[k])*(this->x_val[j]-this->x_val[k])+ 
     
    196196                } 
    197197                I_out[i] = sumj; 
    198                 if (is_sym == 1){ 
     198                if (this->is_avg == 1) { 
    199199                        I_out[i] *= sumj; 
    200200                } 
Note: See TracChangeset for help on using the changeset viewer.