1 /* 2 * Grace - GRaphing, Advanced Computation and Exploration of data 3 * 4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/ 5 * 6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR 7 * Copyright (c) 1996-2000 Grace Development Team 8 * 9 * Maintained by Evgeny Stambulchik 10 * 11 * 12 * All Rights Reserved 13 * 14 * This program is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU General Public License as published by 16 * the Free Software Foundation; either version 2 of the License, or 17 * (at your option) any later version. 18 * 19 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 */ 28 29 /* cmath.h - replacement for math.h or missing in libm functions */ 30 31 #include <config.h> 32 33 #if defined(HAVE_MATH_H) 34 # include <math.h> 35 #endif 36 #if defined(HAVE_FLOAT_H) 37 # include <float.h> 38 #endif 39 #if defined(HAVE_IEEEFP_H) 40 # include <ieeefp.h> 41 #endif 42 43 #ifndef __GRACE_SOURCE_ 44 45 #ifndef MACHEP 46 extern double MACHEP; 47 #endif 48 49 #ifndef UFLOWTHRESH 50 extern double UFLOWTHRESH; 51 #endif 52 53 #ifndef MAXNUM 54 extern double MAXNUM; 55 #endif 56 57 #endif /* __GRACE_SOURCE_ */ 58 59 #ifndef M_PI 60 # define M_PI 3.14159265358979323846 61 #endif 62 63 #ifndef M_SQRT2 64 # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ 65 #endif 66 67 #ifndef M_SQRT1_2 68 # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ 69 #endif 70 71 #ifndef M_SQRT1_3 72 # define M_SQRT1_3 0.57735026918962576451 /* 1/sqrt(3) */ 73 #endif 74 75 #ifndef HAVE_HYPOT 76 # define hypot(x, y) sqrt((x)*(x) + (y)*(y)) 77 #endif 78 79 extern double round ( double x ); 80 #ifndef HAVE_RINT 81 # define rint round 82 #else 83 # ifndef HAVE_RINT_DECL 84 extern double rint ( double x ); 85 # endif 86 #endif 87 88 #ifndef HAVE_CBRT_DECL 89 extern double cbrt ( double x ); 90 #endif 91 92 /* Cygnus gnuwin32 has the log2 macro */ 93 #ifdef log2 94 # undef log2 95 #endif 96 97 #ifndef HAVE_LOG2_DECL 98 extern double log2 ( double x ); 99 #endif 100 101 #ifndef HAVE_LGAMMA 102 extern int sgngam; 103 # define lgamma lgam 104 # define signgam sgngam 105 extern double lgam ( double x ); 106 #else 107 # ifndef HAVE_LGAMMA_DECL 108 extern double lgamma ( double x ); 109 # endif 110 # ifndef HAVE_SIGNGAM_DECL 111 extern int signgam; 112 # endif 113 # define lgam lgamma 114 # define sgngam signgam 115 #endif 116 117 #ifndef HAVE_ACOSH_DECL 118 extern double acosh ( double x ); 119 #endif 120 121 #ifndef HAVE_ASINH_DECL 122 extern double asinh ( double x ); 123 #endif 124 125 #ifndef HAVE_ATANH_DECL 126 extern double atanh ( double x ); 127 #endif 128 129 #ifndef HAVE_ERF_DECL 130 extern double erf ( double x ); 131 #endif 132 133 #ifndef HAVE_ERFC_DECL 134 extern double erfc ( double x ); 135 #endif 136 137 #ifndef HAVE_Y0_DECL 138 extern double y0 ( double x ); 139 #endif 140 #ifndef HAVE_Y1_DECL 141 extern double y1 ( double x ); 142 #endif 143 #ifndef HAVE_YN_DECL 144 extern double yn ( int n, double x ); 145 #endif 146 #ifndef HAVE_J0_DECL 147 extern double j0 ( double x ); 148 #endif 149 #ifndef HAVE_J1_DECL 150 extern double j1 ( double x ); 151 #endif 152 #ifndef HAVE_JN_DECL 153 extern double jn ( int n, double x ); 154 #endif 155 156 /* isfinite is a macro */ 157 #ifdef isfinite 158 # define HAVE_ISFINITE_MACRO 159 #endif 160 161 #ifndef HAVE_FINITE 162 # define finite isfinite 163 # if !defined(HAVE_ISFINITE_DECL) && !defined(HAVE_ISFINITE_MACRO) 164 extern int isfinite ( double x ); 165 # endif 166 #else 167 # ifndef HAVE_FINITE_DECL 168 extern int finite ( double x ); 169 # endif 170 #endif 171 172 /* isnan is a macro */ 173 #ifdef isnan 174 # define HAVE_ISNAN_MACRO 175 #endif 176 177 #if !defined(HAVE_ISNAN_DECL) && !defined(HAVE_ISNAN_MACRO) 178 extern int isnan ( double x ); 179 #endif 180