Ignore:
Timestamp:
Oct 26, 2010 3:32:14 PM (12 years ago)
Author:
srkline
Message:

Changes to DebyeSpheres? to convert everything to double, rather than float.

Changes to MonteCarlo? to use a local definition of round(), since it's not a standard function in Visual Studio's math.h. Easier to just write my own and give it an odd name - MC_round()

File:
1 edited

Legend:

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

    r711 r758  
    1616#include "DebyeSpheres.h" 
    1717 
     18 
     19// this function is here simply because MS visual studio does not contain lround() or round() in math.h 
     20// rounds away from zero 
     21// -- only used in FindPixel 
     22long MC_round(double x) 
     23{ 
     24        if(x == 0)      { 
     25                return (long)(0); 
     26        } 
     27        if(x > 0)       { 
     28                return (long)(x + 0.5f); 
     29        } else {                // x < 0 
     30                return (long)(x - 0.5f); 
     31        } 
     32} 
     33 
     34 
    1835int 
    1936FindPixel(double testQ, double testPhi, double lam, double sdd, 
     
    2946        theta = 2.0*asin(qy*lam/4.0/pi); 
    3047        dy = sdd*tan(theta); 
    31         *yPixel = lround(yCtr + dy/pixSize);            //corrected 7/2010 to round away from zero, to avoid 2x counts in row 0 and column 0 
     48//      *yPixel = lround(yCtr + dy/pixSize);            //corrected 7/2010 to round away from zero, to avoid 2x counts in row 0 and column 0 
     49        *yPixel = MC_round(yCtr + dy/pixSize);          //corrected 7/2010 to round away from zero, to avoid 2x counts in row 0 and column 0 
    3250         
    3351        theta = 2.0*asin(qx*lam/4.0/pi); 
    3452        dx = sdd*tan(theta); 
    35         *xPixel = lround(xCtr + dx/pixSize); 
     53//      *xPixel = lround(xCtr + dx/pixSize); 
     54        *xPixel = MC_round(xCtr + dx/pixSize); 
    3655         
    3756        //if on detector, return xPix and yPix values, otherwise -1 
Note: See TracChangeset for help on using the changeset viewer.