/**************************************/ /**** GENERAL MACRO DEFINITIONS *******/ /**************************************/ # ifndef MAX # define MAX(a,b) (((a) > (b)) ? (a) : (b)) # endif # ifndef MIN # define MIN(a,b) (((a) < (b)) ? (a) : (b)) # endif # define CLIP(a,i,s) (((a) > (s)) ? (s) : MAX(a,i)) # define INT(a) ((Int) (floor((Double) a))) # define MNINT(a) ((a) < 0 ? (Int)(a - 0.5) : (Int)(a + 0.5)) # define MAX3(x,y,z) MAX(MAX(x,y),z) # define MIN3(x,y,z) MIN(MIN(x,y),z) # define MEDIAN(x,y,z) ((x)+(y)+(z)-MAX3(x,y,z)-MIN3(x,y,z)) # define POW2(a) ((a)*(a)) # define SQUARE(a) ((a)*(a)) # define POW3(a) ((a)*(a)*(a)) # define CUBE(a) ((a)*(a)*(a)) # define ABS(x) (((x) < 0) ? -(x) : (x)) # define SIGN(x) (((x) < 0) ? -1 : 1) # define EVEN(a) ((a) % 2) == 0) # define ODD(a) ((a) % 2) == 1) # define STRLEN(P_string) ((P_string==NULL) ? strlen(P_string) : -1) # define TYPE_MALLOC(type,nb) ((type *) malloc(sizeof(type)*nb)) # define NEW(type) ((type *) malloc(sizeof(type) )) #define MOMCHECK(a) if ((a) == 0) fprintf(stdout, "MOMCHECK failed in file %s, line %i/n", __FILE__, __LINE__)