Back to index

texmacs  1.0.7.15
math_util.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : math_util.hpp
00004 * DESCRIPTION: extra math functions
00005 * COPYRIGHT  : (C) 2003  Henri Lesourd
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef MATH_UTIL_H
00013 #define MATH_UTIL_H
00014 #include "tree.hpp"
00015 
00016 const  double tm_infinity=3.40282347e+38F;
00017 const  double tm_PI=3.1415926535897932384626433832795029L;
00018 const  double tm_E =2.7182818284590452353602874713526625L;
00019 
00020 inline double square (double x) { return x*x; }
00021 inline double norm (double x) { return x>0?x:-x; }
00022 inline double nearest (double x) { // round missing in some math.h
00023   return floor (x+0.5); }
00024 inline int    sign (double x) { return x>0?1:x<0?-1:0; } 
00025 inline bool   fnull (double x, double approx) { return norm(x) <= approx; }
00026 #ifndef __SUNPRO_CC
00027 inline double pow (double x, int n) {
00028   if (n<=0) return 1; n--; while (n--) x*=x; return x; }
00029 #endif
00030 
00031 
00032 #endif // defined MATH_UTIL_H