aGrUM  0.13.2

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

+ Collaboration diagram for Math:

Detailed Description

All the maths you'll need.

Classes

class  gum::Formula
 Evaluates a string as a algebraic formula. More...
 
class  gum::Chi2
 Represent 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...
 

Integers Pow utility methods

unsigned long gum::intPow (unsigned long base, unsigned long exponent)
 Specialized pow function with integers (faster implementation). More...
 
unsigned long gum::int2Pow (unsigned long exponent)
 Specialized base 2 pow function with integer. More...
 
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. More...
 

Function Documentation

INLINE unsigned long gum::int2Pow ( unsigned long  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 46 of file pow_inl.h.

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

46 { return 1UL << exponent; }

+ Here is the caller graph for this function:

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 33 of file pow_inl.h.

Referenced by gum::credal::CNLoopyPropagation< GUM_SCALAR >::_compute_ext().

33  {
34  if (exponent == 0) { return 1UL; }
35 
36  unsigned long out = base;
37 
38  for (unsigned long i = 1; i < exponent; i++)
39  out *= base;
40 
41  return out;
42  }

+ Here is the caller graph for this function:

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 52 of file pow_inl.h.

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

54  {
55  if (card == 0) {
56  num_bits = 0;
57  new_card = 1;
58  return;
59  }
60 
61  num_bits = 1;
62  new_card = 2;
63 
64  while (new_card < card) {
65  new_card *= 2;
66  num_bits++;
67  }
68  }

+ Here is the caller graph for this function: