aGrUM  0.13.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 #include <cmath>
31 
32 #include <limits>
33 #include <vector>
34 
35 #include <agrum/agrum.h>
36 #include <agrum/core/math/math.h>
37 
38 namespace gum {
39 
46  class GammaLog2 {
47  public:
48  // ============================================================================
50  // ============================================================================
52 
57  GammaLog2(bool requires_precision = false);
58 
63  GammaLog2(const GammaLog2& from);
64 
69  GammaLog2(GammaLog2&& from);
70 
74  ~GammaLog2();
75 
77  // ============================================================================
79  // ============================================================================
81 
86  double operator()(double x) const;
87 
92  void setPrecision(bool p);
93 
95  // ============================================================================
97  // ============================================================================
99 
106  double gammaLog2(double x) const;
107 
109 
110  private:
112  bool __requires_precision{false};
113 
115  static constexpr double __1log2{M_LOG2E};
116 
118  static constexpr double __log_sqrt_2pi{GUM_LOG_SQRT_2PI};
119 
121  static const std::vector< double > __small_values;
122  };
123 
124 } /* namespace gum */
125 
126 #ifndef GUM_NO_INLINE
128 #endif // GUM_NO_INLINE
129 
130 #endif /* GUM_GAMMA_LOG2_H */
Useful macros for maths.
The class for computing Log2 (Gamma(x))
Definition: gammaLog2.h:46
double operator()(double x) const
Returns log2 ( gamma (x) ) for x > 0.
Definition: gammaLog2_inl.h:52
double gammaLog2(double x) const
Returns log2 ( gamma (x) ) for x >= 0.
Definition: gammaLog2_inl.h:29
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:118
bool __requires_precision
Indicates whether we need more precision for small values.
Definition: gammaLog2.h:112
#define GUM_LOG_SQRT_2PI
Definition: math.h:41
#define M_LOG2E
Definition: math.h:33
~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:121
The class for computing Log2 (Gamma(x)).
static constexpr double __1log2
The value of 1 / std::log(2).
Definition: gammaLog2.h:115