#ifndef FPEUND
#ifdef NONDP
#include <nondp.h>
#endif
/**
*
* Structure to hold information about math exceptions
*
*/

struct exception 
	{
	int type;		/* error type */
	char *name;		/* math function name */
	double arg1, arg2; 	/* function arguments */
	double retval;		/* proposed return value */
	};

/*
*
* Exception type codes, found in exception.type
*
*/

#define DOMAIN    1	/* domain error */
#define SING      2	/* singularity */
#define OVERFLOW  3	/* overflow */
#define UNDERFLOW 4	/* underflow */
#define TLOSS	  5	/* total loss of significance */
#define PLOSS	  6	/* partial loss of significance */

/**
*
* Error codes generated by basic arithmetic operations (+ - * /)
*
*/

#define FPEUND 1	/* underflow */
#define FPEOVF 2	/* overflow */
#define FPEZDV 3	/* zero divisor */
#define FPENAN 4	/* not a number (invalid operation) */
#define FPECOM 5	/* not comparable */
 
/**
*
* Constants 
*
*/

#define PI   3.14159265358979323846
#define PID2 1.57079632679489661923	/* PI divided by 2 */
#define PID4 0.78539816339744830962	/* PI divided by 4 */
#define I_PI 0.31830988618379067154	/* Inverse of PI */
#define I_PID2 0.63661977236758134308	/* Inverse of PID2 */
 
#define HUGE 1.797693e308		/* huge value */
#define HUGE_VAL 1.797693e308		/* huge value */
#define TINY 2.2e-308			/* tiny value */
#define LOGHUGE 709.778			/* natural log of huge value */
#define LOGTINY -708.396		/* natural log of tiny value */

/**
*
* External declarations
*
*/

extern int _FPERR;	/* floating point arithmetic error */
extern int errno;	/* UNIX error code */

#ifndef __ARGS
#ifdef NARGS
#define __ARGS(a) ()
#else
#define __ARGS(a) a
#endif
#endif

extern double acos __ARGS((double));
extern double asin __ARGS((double));
extern double atan __ARGS((double));
extern double atan2 __ARGS((double, double));
extern double atof __ARGS((char *));
extern double ceil __ARGS((double));
extern double cos __ARGS((double));
extern double cosh __ARGS((double));
extern double cot __ARGS((double));
extern void CXFERR __ARGS((int));
extern double drand48 __ARGS((void)); 
extern char *ecvt __ARGS((double, int, int *, int *));
extern double erand48 __ARGS((unsigned short *));
extern double except __ARGS((int, char *, double, double, double));
extern double exp __ARGS((double));
extern double fabs __ARGS((double));
extern char *fcvt __ARGS((double, int, int *, int *));
extern double floor __ARGS((double));
extern double fmod __ARGS((double, double));
extern double frexp __ARGS((double, int *));
extern char *gcvt __ARGS((double, int, char *));
extern long jrand48 __ARGS((unsigned short *));
extern double ldexp __ARGS((double, int));
extern void lcong48 __ARGS((unsigned short *));
extern double log __ARGS((double));
extern double log10 __ARGS((double));
extern long lrand48 __ARGS((void));
extern int matherr __ARGS((struct exception *));
extern double modf __ARGS((double, double *));
extern long mrand48 __ARGS((void));
extern long nrand48 __ARGS((unsigned short *));
extern double pow __ARGS((double, double));
extern double pow2 __ARGS((double));
extern int rand __ARGS((void));
extern unsigned short *seed48 __ARGS((unsigned short *));
extern double sin __ARGS((double));
extern double sinh __ARGS((double));
extern double sqrt __ARGS((double));
extern void srand __ARGS((unsigned));
extern void srand48 __ARGS((long));
extern double tan __ARGS((double));
extern double tanh __ARGS((double));

/**
*
* Macros
*
*/

#ifndef abs
#define abs(x) ((x)<0?-(x):(x))
#endif
#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<=(b)?(a):(b))
#endif
#endif
