Changeset 7e82256 in sasview for src/sas/sascalc/calculator
- Timestamp:
- Nov 13, 2017 11:51:56 AM (7 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:
- 95d7c4f
- Parents:
- f926abb
- Location:
- src/sas/sascalc/calculator/c_extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/c_extensions/sld2i.c
r54b0650 r7e82256 65 65 66 66 double count = 0.0; 67 //check if this computation is for averaging67 int i, j; 68 68 69 69 //Assume that pixel volumes are given in vol_pix in A^3 unit … … 75 75 76 76 //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 77 for(i nt i=0; i<npoints; i++){77 for(i=0; i<npoints; i++){ 78 78 //I_out[i] = 0.0; 79 79 sumj_uu = cassign(0.0, 0.0); … … 84 84 //q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]); 85 85 86 for( intj=0; j<this->n_pix; j++){86 for(j=0; j<this->n_pix; j++){ 87 87 if (this->sldn_val[j]!=0.0 88 88 ||this->mx_val[j]!=0.0 … … 156 156 double sld_j = 0.0; 157 157 double count = 0.0; 158 int i, j, k; 159 158 160 //Assume that pixel volumes are given in vol_pix in A^3 unit 159 161 // Loop over q-values and multiply apply matrix 160 for(i nt i=0; i<npoints; i++){162 for(i=0; i<npoints; i++){ 161 163 sumj =0.0; 162 for( intj=0; j<this->n_pix; j++){164 for(j=0; j<this->n_pix; j++){ 163 165 //Isotropic: Assumes all slds are real (no magnetic) 164 166 //Also assumes there is no polarization: No dependency on spin … … 177 179 //full calculation 178 180 //pragma omp parallel for 179 for( intk=0; k<this->n_pix; k++){181 for(k=0; k<this->n_pix; k++){ 180 182 sld_j = this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k]; 181 183 qr = (this->x_val[j]-this->x_val[k])*(this->x_val[j]-this->x_val[k])+ -
src/sas/sascalc/calculator/c_extensions/sld2i_module.c
r54b0650 r7e82256 4 4 #include <Python.h> 5 5 #include <stdio.h> 6 #include <sld2i.h>6 #include "sld2i.h" 7 7 8 8 #if PY_MAJOR_VERSION < 3 … … 68 68 double outspin; 69 69 double stheta; 70 PyObject *obj; 71 GenI* sld2i; 70 72 71 73 if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &is_avg, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL; … … 78 80 INVECTOR(mz_val_obj, mz_val, n_mz); 79 81 INVECTOR(vol_pix_obj, vol_pix, n_vol_pix); 80 GenI*sld2i = PyMem_Malloc(sizeof(GenI));82 sld2i = PyMem_Malloc(sizeof(GenI)); 81 83 //printf("sldi:%p\n", sld2i); 82 84 if (sld2i != NULL) { 83 initGenI(sld2i,is_avg, n_x,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta);85 initGenI(sld2i,is_avg,(int)n_x,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta); 84 86 } 85 PyObject *obj = PyCapsule_New(sld2i, "GenI", del_sld2i);87 obj = PyCapsule_New(sld2i, "GenI", del_sld2i); 86 88 //printf("constructed %p\n", obj); 87 89 return obj; … … 100 102 double *qy; 101 103 double *I_out; 104 GenI* sld2i; 102 105 103 106 if (!PyArg_ParseTuple(args, "OOOO", &gen_obj, &qx_obj, &qy_obj, &I_out_obj)) return NULL; 104 GenI*sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI");107 sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 105 108 INVECTOR(qx_obj, qx, n_qx); 106 109 INVECTOR(qy_obj, qy, n_qy); … … 110 113 //if(n_q!=n_out) return Py_BuildValue("i",-1); 111 114 112 genicomXY(sld2i, n_qx, qx, qy, I_out);115 genicomXY(sld2i, (int)n_qx, qx, qy, I_out); 113 116 //return PyCObject_FromVoidPtr(s, del_genicom); 114 117 return Py_BuildValue("i",1); … … 125 128 double *q; 126 129 double *I_out; 130 GenI *sld2i; 127 131 128 132 if (!PyArg_ParseTuple(args, "OOO", &gen_obj, &q_obj, &I_out_obj)) return NULL; 129 GenI *sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI");133 sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 130 134 INVECTOR(q_obj, q, n_q); 131 135 OUTVECTOR(I_out_obj, I_out, n_out); … … 134 138 //if (n_q!=n_out) return Py_BuildValue("i",-1); 135 139 136 genicom(sld2i, n_q, q, I_out);140 genicom(sld2i, (int)n_q, q, I_out); 137 141 return Py_BuildValue("i",1); 138 142 }
Note: See TracChangeset
for help on using the changeset viewer.