Ignore:
Timestamp:
Apr 9, 2010 1:46:29 PM (13 years ago)
Author:
srkline
Message:

Changing the round() call to properly return (long) and be compatibile with VC8.

Location:
sans/XOP_Dev/MonteCarlo
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sans/XOP_Dev/MonteCarlo/MonteCarlo.c

    r623 r673  
    1313#include "DebyeSpheres.h" 
    1414 
    15 static int gCallSpinProcess = 1;                // Set to 1 to all user abort (cmd dot) and background processing. 
     15//static int gCallSpinProcess = 1;              // Set to 1 to all user abort (cmd dot) and background processing. 
    1616 
    1717////////// 
     
    6060        long n1,n2,n3; 
    6161        double dth,zz,xx,yy,phi; 
    62         double theta,ran,ll,rr,ttot; 
     62        double theta,ran,ll,rr; 
    6363        long done,find_theta,err;               //used as logicals 
    6464        long xPixel,yPixel; 
     
    7373        // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 
    7474        waveHndl wavH; 
    75         int waveType,hState; 
     75//      int waveType,hState; 
    7676        long numDimensions; 
    7777        long dimensionSizes[MAX_DIMENSIONS+1]; 
    78         char* dataStartPtr; 
    79         long dataOffset; 
    80         long numRows, numColumns,numRows_ran_dev; 
    81         double *dp0, *dp, value[2];                             // Pointers used for double data. 
     78//      char* dataStartPtr; 
     79//      long dataOffset; 
     80//      long numRows, numColumns; 
     81        long numRows_ran_dev; 
     82//      double *dp0, *dp;  
     83        double value[2];                                // Pointers used for double data. 
    8284        long seed; 
    8385        long indices[MAX_DIMENSIONS]; 
    8486         
    85         char buf[256]; 
     87//      char buf[256]; 
    8688                 
    8789        /* check that wave handles are all valid */ 
     
    154156        sig_incoh = inputWave[9]; 
    155157        sig_sas = inputWave[10]; 
    156         xCtr_long = round(xCtr); 
    157         yCtr_long = round(yCtr); 
     158        xCtr_long = (long)(xCtr+0.5); 
     159        yCtr_long = (long)(yCtr+0.5); 
    158160         
    159161        dummy = MDGetWaveScaling(p->ran_devH, 0, &delta, &left);                //0 is the rows 
     
    368370                                                //Choose index for scattering angle array. 
    369371                                                //IND = NINT(THETA_z/DTH + 0.4999999) 
    370                                                 ind = round(theta_z/dth + 0.4999999);           //round is eqivalent to nint() 
     372                                                ind = (long)(theta_z/dth + 0.4999999);          //round is eqivalent to nint() 
    371373                                                nt[ind] += 1;                   //Increment bin for angle. 
    372374                                                //Increment angle array for single scattering events. 
     
    408410                                                //indices[0] = xCtr_long;               //don't put everything in one pixel 
    409411                                                //indices[1] = yCtr_long; 
    410                                                 indices[0] = (long)round(xCtr+xx/pixSize); 
    411                                                 indices[1] = (long)round(yCtr+yy/pixSize); 
     412                                                indices[0] = (long)(xCtr+xx/pixSize+0.5); 
     413                                                indices[1] = (long)(yCtr+yy/pixSize+0.5); 
    412414                                                // check for valid indices - got an XOP error, probably from here 
    413415                                                if(indices[0] > 127) indices[0] = 127; 
     
    483485        theta = 2.0*asin(qy*lam/4.0/pi); 
    484486        dy = sdd*tan(theta); 
    485         *yPixel = round(yCtr + dy/pixSize); 
     487        *yPixel = (long)(yCtr + dy/pixSize+0.5); 
    486488         
    487489        theta = 2.0*asin(qx*lam/4.0/pi); 
    488490        dx = sdd*tan(theta); 
    489         *xPixel = round(xCtr + dx/pixSize); 
     491        *xPixel = (long)(xCtr + dx/pixSize+0.5); 
    490492 
    491493        //if on detector, return xPix and yPix values, otherwise -1 
  • sans/XOP_Dev/MonteCarlo/MonteCarlo.r

    r623 r673  
    1616        { 
    1717                /* [1] */ 
    18                 "WaveAccess requires Igor Pro 5.0 or later.", 
     18                "SANSMonteCarlo requires Igor Pro 6.1 or later.", 
    1919                /* [2] */ 
    2020                "Wave does not exist.", 
  • sans/XOP_Dev/MonteCarlo/MonteCarlo2.c

    r623 r673  
    1212#include "MonteCarlo.h" 
    1313 
    14 static int gCallSpinProcess = 1;                // Set to 1 to all user abort (cmd dot) and background processing. 
     14//static int gCallSpinProcess = 1;              // Set to 1 to all user abort (cmd dot) and background processing. 
    1515 
    1616// these versions are DIRECT COPIES of the main version in MonteCarlo.c 
     
    4141        long n1,n2,n3; 
    4242        double dth,zz,xx,yy,phi; 
    43         double theta,ran,ll,rr,ttot; 
     43        double theta,ran,ll,rr; 
    4444        long done,find_theta,err;               //used as logicals 
    4545        long xPixel,yPixel; 
     
    5555        // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 
    5656        waveHndl wavH; 
    57         int waveType,hState; 
     57//      int waveType,hState; 
    5858        long numDimensions; 
    5959        long dimensionSizes[MAX_DIMENSIONS+1]; 
    60         char* dataStartPtr; 
    61         long dataOffset; 
    62         long numRows, numColumns,numRows_ran_dev; 
    63         double *dp0, *dp, value[2];                             // Pointers used for double data. 
     60//      char* dataStartPtr; 
     61//      long dataOffset; 
     62//      long numRows, numColumns; 
     63        long numRows_ran_dev; 
     64//      double *dp0, *dp; 
     65        double value[2];                                // Pointers used for double data. 
    6466        long seed; 
    6567        long indices[MAX_DIMENSIONS]; 
    6668         
    67         char buf[256]; 
     69//      char buf[256]; 
    6870                 
    6971        /* check that wave handles are all valid */ 
     
    136138        sig_incoh = inputWave[9]; 
    137139        sig_sas = inputWave[10]; 
    138         xCtr_long = round(xCtr); 
    139         yCtr_long = round(yCtr); 
     140        xCtr_long = (long)(xCtr+0.5); 
     141        yCtr_long = (long)(yCtr+0.5); 
    140142         
    141143        dummy = MDGetWaveScaling(p->ran_devH, 0, &delta, &left);                //0 is the rows 
     
    350352                                                //Choose index for scattering angle array. 
    351353                                                //IND = NINT(THETA_z/DTH + 0.4999999) 
    352                                                 ind = round(theta_z/dth + 0.4999999);           //round is eqivalent to nint() 
     354                                                ind = (long)(theta_z/dth + 0.4999999);          //round is eqivalent to nint() 
    353355                                                nt[ind] += 1;                   //Increment bin for angle. 
    354356                                                //Increment angle array for single scattering events. 
     
    390392                                                //indices[0] = xCtr_long;               //don't put everything in one pixel 
    391393                                                //indices[1] = yCtr_long; 
    392                                                 indices[0] = (long)round(xCtr+xx/pixSize); 
    393                                                 indices[1] = (long)round(yCtr+yy/pixSize); 
     394                                                indices[0] = (long)(xCtr+xx/pixSize+0.5); 
     395                                                indices[1] = (long)(yCtr+yy/pixSize+0.5); 
    394396                                                // check for valid indices - got an XOP error, probably from here 
    395397                                                if(indices[0] > 127) indices[0] = 127; 
     
    472474        long n1,n2,n3; 
    473475        double dth,zz,xx,yy,phi; 
    474         double theta,ran,ll,rr,ttot; 
     476        double theta,ran,ll,rr; 
    475477        long done,find_theta,err;               //used as logicals 
    476478        long xPixel,yPixel; 
     
    486488        // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 
    487489        waveHndl wavH; 
    488         int waveType,hState; 
     490//      int waveType,hState; 
    489491        long numDimensions; 
    490492        long dimensionSizes[MAX_DIMENSIONS+1]; 
    491         char* dataStartPtr; 
    492         long dataOffset; 
    493         long numRows, numColumns,numRows_ran_dev; 
    494         double *dp0, *dp, value[2];                             // Pointers used for double data. 
     493//      char* dataStartPtr; 
     494//      long dataOffset; 
     495//      long numRows, numColumns; 
     496        long numRows_ran_dev; 
     497//      double *dp0, *dp; 
     498        double value[2];                                // Pointers used for double data. 
    495499        long seed; 
    496500        long indices[MAX_DIMENSIONS]; 
    497501         
    498         char buf[256]; 
     502//      char buf[256]; 
    499503                 
    500504        /* check that wave handles are all valid */ 
     
    567571        sig_incoh = inputWave[9]; 
    568572        sig_sas = inputWave[10]; 
    569         xCtr_long = round(xCtr); 
    570         yCtr_long = round(yCtr); 
     573        xCtr_long = (long)(xCtr+0.5); 
     574        yCtr_long = (long)(yCtr+0.5); 
    571575         
    572576        dummy = MDGetWaveScaling(p->ran_devH, 0, &delta, &left);                //0 is the rows 
     
    781785                                                //Choose index for scattering angle array. 
    782786                                                //IND = NINT(THETA_z/DTH + 0.4999999) 
    783                                                 ind = round(theta_z/dth + 0.4999999);           //round is eqivalent to nint() 
     787                                                ind = (long)(theta_z/dth + 0.4999999);          //round is eqivalent to nint() 
    784788                                                nt[ind] += 1;                   //Increment bin for angle. 
    785789                                                //Increment angle array for single scattering events. 
     
    821825                                                //indices[0] = xCtr_long;               //don't put everything in one pixel 
    822826                                                //indices[1] = yCtr_long; 
    823                                                 indices[0] = (long)round(xCtr+xx/pixSize); 
    824                                                 indices[1] = (long)round(yCtr+yy/pixSize); 
     827                                                indices[0] = (long)(xCtr+xx/pixSize+0.5); 
     828                                                indices[1] = (long)(yCtr+yy/pixSize+0.5); 
    825829                                                // check for valid indices - got an XOP error, probably from here 
    826830                                                if(indices[0] > 127) indices[0] = 127; 
     
    902906        long n1,n2,n3; 
    903907        double dth,zz,xx,yy,phi; 
    904         double theta,ran,ll,rr,ttot; 
     908        double theta,ran,ll,rr; 
    905909        long done,find_theta,err;               //used as logicals 
    906910        long xPixel,yPixel; 
     
    916920        // for accessing the 2D wave data, direct method (see the WaveAccess example XOP) 
    917921        waveHndl wavH; 
    918         int waveType,hState; 
     922//      int waveType,hState; 
    919923        long numDimensions; 
    920924        long dimensionSizes[MAX_DIMENSIONS+1]; 
    921         char* dataStartPtr; 
    922         long dataOffset; 
    923         long numRows, numColumns,numRows_ran_dev; 
    924         double *dp0, *dp, value[2];                             // Pointers used for double data. 
     925//      char* dataStartPtr; 
     926//      long dataOffset; 
     927//      long numRows, numColumns; 
     928        long numRows_ran_dev; 
     929//      double *dp0, *dp; 
     930        double value[2];                                // Pointers used for double data. 
    925931        long seed; 
    926932        long indices[MAX_DIMENSIONS]; 
    927933         
    928         char buf[256]; 
     934//      char buf[256]; 
    929935                 
    930936        /* check that wave handles are all valid */ 
     
    9971003        sig_incoh = inputWave[9]; 
    9981004        sig_sas = inputWave[10]; 
    999         xCtr_long = round(xCtr); 
    1000         yCtr_long = round(yCtr); 
     1005        xCtr_long = (long)(xCtr+0.5); 
     1006        yCtr_long = (long)(yCtr+0.5); 
    10011007         
    10021008        dummy = MDGetWaveScaling(p->ran_devH, 0, &delta, &left);                //0 is the rows 
     
    12111217                                                //Choose index for scattering angle array. 
    12121218                                                //IND = NINT(THETA_z/DTH + 0.4999999) 
    1213                                                 ind = round(theta_z/dth + 0.4999999);           //round is eqivalent to nint() 
     1219                                                ind = (long)(theta_z/dth + 0.4999999);          //round is eqivalent to nint() 
    12141220                                                nt[ind] += 1;                   //Increment bin for angle. 
    12151221                                                //Increment angle array for single scattering events. 
     
    12511257                                                //indices[0] = xCtr_long;               //don't put everything in one pixel 
    12521258                                                //indices[1] = yCtr_long; 
    1253                                                 indices[0] = (long)round(xCtr+xx/pixSize); 
    1254                                                 indices[1] = (long)round(yCtr+yy/pixSize); 
     1259                                                indices[0] = (long)(xCtr+xx/pixSize+0.5); 
     1260                                                indices[1] = (long)(yCtr+yy/pixSize+0.5); 
    12551261                                                // check for valid indices - got an XOP error, probably from here 
    12561262                                                if(indices[0] > 127) indices[0] = 127; 
Note: See TracChangeset for help on using the changeset viewer.