00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #if !defined(MATH_NUM_H)
00018 #define MATH_NUM_H 1
00019
00020 #ifdef __GNUC__
00021 #if ! defined(TWINE)
00022
00023 #endif
00024 #endif
00025
00026 #include <float.h>
00027 #include <math.h>
00028 #include "haio.h"
00029 #include "builtin.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 void message(const char * message,...);
00043
00044 #ifndef assert
00045 #define assert(ex) \
00046 (void)((ex) ? 1 : \
00047 (fprintf(stderr,"Failed assertion " #ex " at line %d of `%s'.\n", \
00048 __LINE__, __FILE__), 0))
00049 #define assertval(ex) assert(ex)
00050 #endif
00051
00052 #define assure(expr,message) \
00053 if (expr) {;} \
00054 else fprintf(stderr,"%s\n at line %d of '%s'.",message,__LINE__, __FILE__)
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 class UnivariateFunctor
00074 {
00075 public:
00076 UnivariateFunctor();
00077 virtual ~UnivariateFunctor();
00078 virtual double operator() (const double x);
00079 virtual int junk_func() { return 1; }
00080 };
00081
00082
00083
00084
00085
00086
00087 double fminbr(const double a, const double b,
00088 UnivariateFunctor& f, const double tol=DBL_EPSILON);
00089
00090 inline int nintf(const double x) { return (fmod(x,1.0) < 0.5) ? (int) x : ((int)x) + 1; }
00091
00092 #endif // !defined (MATH_NUM_H)