aGrUM 3.1.1
a C++ library for (probabilistic) graphical models

All the maths you'll need. More...

Collaboration diagram for Math:

Classes

class  gum::Formula
 Evaluates a string as a algebraic formula. More...
class  gum::Chi2
 Static math utilities for the chi2 distribution. More...
class  gum::Dirichlet
 A class for sampling w.r.t. More...
class  gum::FormulaPart
 Represents part of a formula. More...
class  gum::GammaLog2
 The class for computing Log2 (Gamma(x)). More...
class  gum::Rational< GUM_SCALAR >
 Class template used to approximate decimal numbers by rationals. More...
class  gum::VariableLog2ParamComplexity
 the class for computing the log2 of the parametric complexity of an r-ary multinomial variable More...

Integers Pow utility methods

unsigned long gum::intPow (unsigned long base, unsigned long exponent)
 Specialized pow function with integers (faster implementation).
uint64_t gum::int2Pow (uint64_t exponent)
 Specialized base 2 pow function with integer.
void gum::superiorPow (unsigned long card, unsigned long &num_bits, unsigned long &new_card)
 Compute the superior and closest power of two of an integer.

Detailed Description

All the maths you'll need.

Function Documentation

◆ int2Pow()

INLINE uint64_t gum::int2Pow ( uint64_t exponent)

Specialized base 2 pow function with integer.

Parameters
exponentThe unsigned long integer exponent used to compute \(2^{exponent} \) which will hold the result of afterward.

Definition at line 70 of file pow_inl.h.

70 {
71 if (exponent >= 64) { GUM_ERROR(OutOfBounds, "int2Pow: exponent " << exponent << " >= 64") }
72 return static_cast< uint64_t >(1) << exponent;
73 }
Exception : out of bound.
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References GUM_ERROR.

Referenced by gum::credal::CredalNet< GUM_SCALAR >::approximatedBinarization().

Here is the caller graph for this function:

◆ intPow()

INLINE unsigned long gum::intPow ( unsigned long base,
unsigned long exponent )

Specialized pow function with integers (faster implementation).

Parameters
baseThe constant unsigned long integer base used to compute \(base^{exponent} \).
exponentThe unsigned long integer exponent used which will hold the result afterward.

Definition at line 57 of file pow_inl.h.

57 {
58 if (exponent == 0) { return 1UL; }
59
60 unsigned long out = base;
61
62 for (unsigned long i = 1; i < exponent; i++)
63 out *= base;
64
65 return out;
66 }

◆ superiorPow()

INLINE void gum::superiorPow ( unsigned long card,
unsigned long & num_bits,
unsigned long & new_card )

Compute the superior and closest power of two of an integer.

Given an integer, compute it's - superior - and closest power of two, i.e. the number of bits necessary to represent this integer as well as the maximum integer that can be represented by those bits.

Parameters
cardThe constant unsigned long integer we wish to represent by bits.
num_bitsThe unsigned long integer used as a "return" value to get the minimum number of bits used to represend card.
new_cardThe unsigned long integer used as a "return" value to get the maximum number those bits can represent, i.e. \( 2^{num\_bits} \).

Definition at line 79 of file pow_inl.h.

79 {
80 if (card == 0) {
81 num_bits = 0;
82 new_card = 1;
83 return;
84 }
85
86 num_bits = 1;
87 new_card = 2;
88
89 while (new_card < card) {
90 new_card *= 2;
91 num_bits++;
92 }
93 }

Referenced by gum::credal::CredalNet< GUM_SCALAR >::approximatedBinarization(), and gum::credal::VarMod2BNsMap< GUM_SCALAR >::setCNet().

Here is the caller graph for this function: