/* Switch rounding mode on linux systems, depends on glibc. */ /* Should work both on x86 and x86_64 systems. */ /* Matthias Huesken, University of Wuppertal, 2006. */ #include #include "mex.h" #define ROUND_NEAR FE_TONEAREST #define ROUND_UP FE_UPWARD #define ROUND_DOWN FE_DOWNWARD void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { int rnd; rnd = mxGetScalar(prhs[0]); switch (rnd) { /* round up */ case 1 : fesetround(ROUND_UP); break; /* round to nearest */ case 0 : fesetround(ROUND_NEAR); break; /* round down */ case -1 : fesetround(ROUND_DOWN); break; /* round to nearest */ default : fesetround(ROUND_NEAR); break; } } /* setround */