aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
pow.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Implementation of pow functions with integers, faster than stl
25  * implementation.
26  * @author Matthieu HOURBRACQ and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 #ifndef GUM_MATH_POW_H
30 #define GUM_MATH_POW_H
31 
32 #include <agrum/agrum.h>
33 
34 namespace gum {
35 
36  /// @name Integers Pow utility methods
37  /// @{
38 
39  /**
40  * @brief Specialized pow function with integers (faster implementation).
41  * @ingroup math_group
42  *
43  * @param base The constant unsigned long integer base used to compute \f$
44  * base^{exponent} \f$.
45  * @param exponent The unsigned long integer exponent used which will hold the
46  * result afterward.
47  */
48  unsigned long intPow(unsigned long base, unsigned long exponent);
49 
50  /**
51  * @brief Specialized base 2 pow function with integer.
52  * @ingroup math_group
53  *
54  * @param exponent The unsigned long integer exponent used to compute \f$
55  * 2^{exponent} \f$ which will hold the result of afterward.
56  */
57  unsigned long int2Pow(unsigned long exponent);
58 
59  /**
60  * @brief Compute the superior and closest power of two of an integer.
61  * @ingroup math_group
62  *
63  * Given an integer, compute it's - superior - and closest power of two, i.e.
64  * the number of bits necessary to represent this integer as well as the
65  * maximum integer that can be represented by those bits.
66  *
67  * @param card The constant unsigned long integer we wish to represent by
68  * bits.
69  * @param num_bits The unsigned long integer used as a "return" value to get
70  * the minimum number of bits used to represend card.
71  * @param new_card The unsigned long integer used as a "return" value to get
72  * the maximum number those bits can represent, i.e. \f$ 2^{num\_bits} \f$.
73  */
74  void superiorPow(unsigned long card, unsigned long& num_bits, unsigned long& new_card);
75 
76  /// @}
77 
78 } // namespace gum
79 
80 #ifndef GUM_NO_INLINE
81 # include <agrum/tools/core/math/pow_inl.h>
82 #endif // GUM_NO_INLINE
83 
84 #endif // GUM_MATH_POW_H
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
unsigned long int2Pow(unsigned long exponent)
Specialized base 2 pow function with integer.
Definition: pow_inl.h:48
void superiorPow(unsigned long card, unsigned long &num_bits, unsigned long &new_card)
Compute the superior and closest power of two of an integer.
Definition: pow_inl.h:54
unsigned long intPow(unsigned long base, unsigned long exponent)
Specialized pow function with integers (faster implementation).
Definition: pow_inl.h:35