Changeset 7e82256 in sasview


Ignore:
Timestamp:
Nov 13, 2017 11:51:56 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:
95d7c4f
Parents:
f926abb
Message:

declare all variables at the start of the block so C89 compilers don't complain

Location:
src/sas/sascalc/calculator/c_extensions
Files:
2 edited

Legend:

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

    r54b0650 r7e82256  
    6565 
    6666        double count = 0.0; 
    67         //check if this computation is for averaging 
     67        int i, j; 
    6868 
    6969        //Assume that pixel volumes are given in vol_pix in A^3 unit 
     
    7575 
    7676        //printf("npoints: %d, npix: %d\n", npoints, this->n_pix); 
    77         for(int i=0; i<npoints; i++){ 
     77        for(i=0; i<npoints; i++){ 
    7878                //I_out[i] = 0.0; 
    7979                sumj_uu = cassign(0.0, 0.0); 
     
    8484                //q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]); 
    8585 
    86                 for(int j=0; j<this->n_pix; j++){ 
     86                for(j=0; j<this->n_pix; j++){ 
    8787                        if (this->sldn_val[j]!=0.0 
    8888                                ||this->mx_val[j]!=0.0 
     
    156156        double sld_j = 0.0; 
    157157        double count = 0.0; 
     158        int i, j, k; 
     159 
    158160        //Assume that pixel volumes are given in vol_pix in A^3 unit 
    159161        // Loop over q-values and multiply apply matrix 
    160         for(int i=0; i<npoints; i++){ 
     162        for(i=0; i<npoints; i++){ 
    161163                sumj =0.0; 
    162                 for(int j=0; j<this->n_pix; j++){ 
     164                for(j=0; j<this->n_pix; j++){ 
    163165                        //Isotropic: Assumes all slds are real (no magnetic) 
    164166                        //Also assumes there is no polarization: No dependency on spin 
     
    177179                                //full calculation 
    178180                                //pragma omp parallel for 
    179                                 for(int k=0; k<this->n_pix; k++){ 
     181                                for(k=0; k<this->n_pix; k++){ 
    180182                                        sld_j =  this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k]; 
    181183                                        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  
    44#include <Python.h> 
    55#include <stdio.h> 
    6 #include <sld2i.h> 
     6#include "sld2i.h" 
    77 
    88#if PY_MAJOR_VERSION < 3 
     
    6868        double outspin; 
    6969        double stheta; 
     70        PyObject *obj; 
     71        GenI* sld2i; 
    7072 
    7173        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; 
     
    7880        INVECTOR(mz_val_obj, mz_val, n_mz); 
    7981        INVECTOR(vol_pix_obj, vol_pix, n_vol_pix); 
    80         GenI* sld2i = PyMem_Malloc(sizeof(GenI)); 
     82        sld2i = PyMem_Malloc(sizeof(GenI)); 
    8183        //printf("sldi:%p\n", sld2i); 
    8284        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); 
    8486        } 
    85         PyObject *obj = PyCapsule_New(sld2i, "GenI", del_sld2i); 
     87        obj = PyCapsule_New(sld2i, "GenI", del_sld2i); 
    8688        //printf("constructed %p\n", obj); 
    8789        return obj; 
     
    100102        double *qy; 
    101103        double *I_out; 
     104        GenI* sld2i; 
    102105 
    103106        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"); 
    105108        INVECTOR(qx_obj, qx, n_qx); 
    106109        INVECTOR(qy_obj, qy, n_qy); 
     
    110113        //if(n_q!=n_out) return Py_BuildValue("i",-1); 
    111114 
    112         genicomXY(sld2i, n_qx, qx, qy, I_out); 
     115        genicomXY(sld2i, (int)n_qx, qx, qy, I_out); 
    113116        //return PyCObject_FromVoidPtr(s, del_genicom); 
    114117        return Py_BuildValue("i",1); 
     
    125128        double *q; 
    126129        double *I_out; 
     130        GenI *sld2i; 
    127131 
    128132        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"); 
    130134        INVECTOR(q_obj, q, n_q); 
    131135        OUTVECTOR(I_out_obj, I_out, n_out); 
     
    134138        //if (n_q!=n_out) return Py_BuildValue("i",-1); 
    135139 
    136         genicom(sld2i, n_q, q, I_out); 
     140        genicom(sld2i, (int)n_q, q, I_out); 
    137141        return Py_BuildValue("i",1); 
    138142} 
Note: See TracChangeset for help on using the changeset viewer.