Vaucanson  1.4.1
math.hh
Go to the documentation of this file.
1 // math.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_CONFIG_MATH_HH
18 # define VCSN_CONFIG_MATH_HH
19 
42 
43 # include <cmath>
44 
45 # ifndef USE_C_LIMITS
46 # ifdef HAVE_LIMITS
47 # define USE_CXX_LIMITS
48 # endif
49 # endif
50 
51 # ifdef NEED_SQRTF
52 static inline float sqrtf(float f)
53 {
54  return (float)sqrt((double)f);
55 }
56 # endif
57 
58 # ifdef NEED_FLOORF
59 static inline float floorf(float f)
60 {
61  return (float)floor((double)f);
62 }
63 # endif
64 
65 # ifdef NEED_ROUND
66 static inline double round(double f)
67 {
68  return (f < 0.) ? -floor(-f + 0.5) : floor(f + 0.5);
69 }
70 # endif
71 # ifdef NEED_ROUNDF
72 static inline float roundf(float f)
73 {
74  return (f < 0.f) ? -floorf(-f + 0.5f) : floorf(f + 0.5f);
75 }
76 # endif
77 
78 #endif // ! VCSN_CONFIG_MATH_HH