Some usefull math constants
authorAlpar Juttner <alpar@cs.elte.hu>
Thu, 07 Feb 2008 22:25:42 +0000
changeset 68a315a588a20d
parent 64 761622e5ed4c
child 69 914ffb9b3798
Some usefull math constants

lemon/math.h also includes the standard cmath, so one should prefer using
just lemon/math.h instead of cmath.
lemon/Makefile.am
lemon/math.h
lemon/random.h
     1.1 --- a/lemon/Makefile.am	Mon Feb 04 13:32:36 2008 +0100
     1.2 +++ b/lemon/Makefile.am	Thu Feb 07 22:25:42 2008 +0000
     1.3 @@ -17,6 +17,7 @@
     1.4  lemon_HEADERS += \
     1.5          lemon/dim2.h \
     1.6  	lemon/maps.h \
     1.7 +	lemon/math.h \
     1.8          lemon/random.h \
     1.9  	lemon/list_graph.h \
    1.10          lemon/tolerance.h
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lemon/math.h	Thu Feb 07 22:25:42 2008 +0000
     2.3 @@ -0,0 +1,63 @@
     2.4 +/* -*- C++ -*-
     2.5 + *
     2.6 + * This file is a part of LEMON, a generic C++ optimization library
     2.7 + *
     2.8 + * Copyright (C) 2003-2008
     2.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    2.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    2.11 + *
    2.12 + * Permission to use, modify and distribute this software is granted
    2.13 + * provided that this copyright notice appears in all copies. For
    2.14 + * precise terms see the accompanying LICENSE file.
    2.15 + *
    2.16 + * This software is provided "AS IS" with no warranty of any kind,
    2.17 + * express or implied, and with no claim as to its suitability for any
    2.18 + * purpose.
    2.19 + *
    2.20 + */
    2.21 +
    2.22 +#ifndef LEMON_MATH_H
    2.23 +#define LEMON_MATH_H
    2.24 +
    2.25 +///\ingroup misc
    2.26 +///\file
    2.27 +///\brief Some extensions to the standard \c cmath library.
    2.28 +///
    2.29 +///Some extensions to the standard \c cmath library.
    2.30 +///
    2.31 +///This file includes the standard math library (cmath).
    2.32 +
    2.33 +#include<cmath>
    2.34 +
    2.35 +namespace lemon {
    2.36 +
    2.37 +  /// \addtogroup misc
    2.38 +  /// @{
    2.39 +  
    2.40 +  /// The Euler constant
    2.41 +  const long double E       = 2.7182818284590452353602874713526625L;
    2.42 +  /// log_2(e)
    2.43 +  const long double LOG2E   = 1.4426950408889634073599246810018921L;
    2.44 +  /// log_10(e)
    2.45 +  const long double LOG10E  = 0.4342944819032518276511289189166051L;
    2.46 +  /// ln(2)
    2.47 +  const long double LN2     = 0.6931471805599453094172321214581766L;
    2.48 +  /// ln(10)
    2.49 +  const long double LN10    = 2.3025850929940456840179914546843642L;
    2.50 +  /// pi
    2.51 +  const long double PI      = 3.1415926535897932384626433832795029L;
    2.52 +  /// pi/2
    2.53 +  const long double PI_2    = 1.5707963267948966192313216916397514L;
    2.54 +  /// pi/4
    2.55 +  const long double PI_4    = 0.7853981633974483096156608458198757L;
    2.56 +  /// sqrt(2)
    2.57 +  const long double SQRT2   = 1.4142135623730950488016887242096981L;
    2.58 +  /// 1/sqrt(2)
    2.59 +  const long double SQRT1_2 = 0.7071067811865475244008443621048490L;
    2.60 +  
    2.61 +
    2.62 +  /// @}
    2.63 +
    2.64 +} //namespace lemon
    2.65 +
    2.66 +#endif //LEMON_TOLERANCE_H
     3.1 --- a/lemon/random.h	Mon Feb 04 13:32:36 2008 +0100
     3.2 +++ b/lemon/random.h	Thu Feb 07 22:25:42 2008 +0000
     3.3 @@ -67,9 +67,10 @@
     3.4  #include <vector>
     3.5  
     3.6  #include <ctime>
     3.7 -#include <cmath>
     3.8  
     3.9 +#include <lemon/math.h>
    3.10  #include <lemon/dim2.h>
    3.11 +
    3.12  ///\ingroup misc
    3.13  ///\file
    3.14  ///\brief Mersenne Twister random number generator
    3.15 @@ -759,7 +760,7 @@
    3.16      {
    3.17        double xi,nu;
    3.18        const double delta = k-std::floor(k);
    3.19 -      const double v0=M_E/(M_E-delta);
    3.20 +      const double v0=E/(E-delta);
    3.21        do {
    3.22  	double V0=1.0-real<double>();
    3.23  	double V1=1.0-real<double>();