aGrUM  0.14.2
gammaLog2.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
26 #ifndef GUM_GAMMA_LOG2_H
27 #define GUM_GAMMA_LOG2_H
28 
29 #define _USE_MATH_DEFINES // for Visual C++
30 
31 #include <limits>
32 #include <vector>
33 
34 #include <agrum/agrum.h>
35 #include <agrum/core/math/math.h>
36 
37 namespace gum {
38 
45  class GammaLog2 {
46  public:
47  // ============================================================================
49  // ============================================================================
51 
56  GammaLog2(bool requires_precision = false);
57 
62  GammaLog2(const GammaLog2& from);
63 
68  GammaLog2(GammaLog2&& from);
69 
73  ~GammaLog2();
74 
76  // ============================================================================
78  // ============================================================================
80 
85  double operator()(double x) const;
86 
91  void setPrecision(bool p);
92 
94  // ============================================================================
96  // ============================================================================
98 
105  double gammaLog2(double x) const;
106 
108 
109  private:
111  bool __requires_precision{false};
112 
114  static constexpr double __1log2{M_LOG2E};
115 
117  static constexpr double __log_sqrt_2pi{GUM_LOG_SQRT_2PI};
118 
120  static const std::vector< double > __small_values;
121  };
122 
123 } /* namespace gum */
124 
125 #ifndef GUM_NO_INLINE
127 #endif // GUM_NO_INLINE
128 
129 #endif /* GUM_GAMMA_LOG2_H */
Useful macros for maths.
double gammaLog2(double x) const
Returns log2 ( gamma (x) ) for x >= 0.
Definition: gammaLog2_inl.h:29
The class for computing Log2 (Gamma(x))
Definition: gammaLog2.h:45
void setPrecision(bool p)
Sets whether we need more precision for small values.
Definition: gammaLog2_inl.h:56
GammaLog2(bool requires_precision=false)
Default constructor.
Definition: gammaLog2.cpp:36
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
static constexpr double __log_sqrt_2pi
The value of std::log ( std::sqrt(2pi) ).
Definition: gammaLog2.h:117
bool __requires_precision
Indicates whether we need more precision for small values.
Definition: gammaLog2.h:111
#define GUM_LOG_SQRT_2PI
Definition: math.h:45
#define M_LOG2E
Definition: math.h:33
double operator()(double x) const
Returns log2 ( gamma (x) ) for x > 0.
Definition: gammaLog2_inl.h:52
~GammaLog2()
Class destructor.
Definition: gammaLog2.cpp:54
static const std::vector< double > __small_values
The 5000 values from 0 to 50 by step of 1/100.
Definition: gammaLog2.h:120
The class for computing Log2 (Gamma(x)).
static constexpr double __1log2
The value of 1 / std::log(2).
Definition: gammaLog2.h:114