SNAP Library 2.3, Developer Reference  2014-06-16 11:58:46
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TMath Class Reference

#include <xmath.h>

Static Public Member Functions

static double Inv (const double &x)
 
static double Sqr (const double &x)
 
static double Sqrt (const double &x)
 
static double Log (const double &Val)
 
static double Log2 (const double &Val)
 
static double Round (const double &Val)
 
static double Round (const double &Val, int Decs)
 
static int Fac (const int &Val)
 
static int Choose (const int &N, const int &K)
 
static uint Pow2 (const int &pow)
 
static double Power (const double &Base, const double &Exponent)
 
template<typename T >
static int Sign (const T &Val)
 
template<class T >
static const T & Mx (const T &LVal, const T &RVal)
 
template<class T >
static const T & Mn (const T &LVal, const T &RVal)
 
template<class T >
static const T & Mx (const T &Val1, const T &Val2, const T &Val3)
 
template<class T >
static const T & Mn (const T &Val1, const T &Val2, const T &Val3)
 
template<class T >
static const T & Median (const T &Val1, const T &Val2, const T &Val3)
 
template<class T >
static const T & InRange (const T &Val, const T &Mn, const T &Mx)
 
template<class T >
static bool IsInRange (const T &Val, const T &Mn, const T &Mx)
 
template<class T >
static bool IsInEps (const T &Val, const T &Eps)
 

Static Public Attributes

static double E =2.71828182845904523536
 
static double Pi =3.14159265358979323846
 
static double LogOf2 =log(double(2))
 

Detailed Description

Definition at line 5 of file xmath.h.

Member Function Documentation

static int TMath::Choose ( const int &  N,
const int &  K 
)
inlinestatic

Definition at line 22 of file xmath.h.

References Fac().

22  { // binomial coefficient
23  return Fac(N)/(Fac(K)*Fac(N-K)); }
static int Fac(const int &Val)
Definition: xmath.h:20

Here is the call graph for this function:

static int TMath::Fac ( const int &  Val)
inlinestatic

Definition at line 20 of file xmath.h.

Referenced by Choose().

20  {
21  if (Val<=1){return 1;} else {return Val*Fac(Val-1);}}
static int Fac(const int &Val)
Definition: xmath.h:20

Here is the caller graph for this function:

template<class T >
static const T& TMath::InRange ( const T &  Val,
const T &  Mn,
const T &  Mx 
)
inlinestatic

Definition at line 75 of file xmath.h.

References IAssert.

75  {
76  IAssert(Mn <= Mx); return Val < Mn ? Mn : (Val > Mx ? Mx : Val);}
#define IAssert(Cond)
Definition: bd.h:262
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
static double TMath::Inv ( const double &  x)
inlinestatic

Definition at line 11 of file xmath.h.

References IAssert.

11 {IAssert(x!=0.0); return (1.0/x);}
#define IAssert(Cond)
Definition: bd.h:262
template<class T >
static bool TMath::IsInEps ( const T &  Val,
const T &  Eps 
)
inlinestatic

Definition at line 83 of file xmath.h.

Referenced by TKronMomentsFit::EstABC().

83  {
84  return Val >= -Eps && Val <= Eps;}

Here is the caller graph for this function:

template<class T >
static bool TMath::IsInRange ( const T &  Val,
const T &  Mn,
const T &  Mx 
)
inlinestatic

Definition at line 79 of file xmath.h.

References IAssert, and Mx().

79  {
80  IAssert(Mn <= Mx); return Val >= Mn && Val <= Mx;}
#define IAssert(Cond)
Definition: bd.h:262
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32

Here is the call graph for this function:

static double TMath::Log ( const double &  Val)
inlinestatic

Definition at line 14 of file xmath.h.

Referenced by CalcDescriptionLength(), CalcNonNegativeFactorization(), TCesna::FindComs(), TAGMFast::FindComsByCV(), and TCoda::FindComsByCV().

14 {return log(Val);}

Here is the caller graph for this function:

static double TMath::Log2 ( const double &  Val)
inlinestatic

Definition at line 15 of file xmath.h.

References LogOf2.

Referenced by TGraphAnf< PGraph >::InitAnfBits().

15 {return log(Val)/LogOf2;}
static double LogOf2
Definition: xmath.h:9

Here is the caller graph for this function:

template<class T >
static const T& TMath::Median ( const T &  Val1,
const T &  Val2,
const T &  Val3 
)
inlinestatic

Definition at line 62 of file xmath.h.

62  {
63  if (Val1 < Val2) {
64  if (Val2 < Val3) return Val2;
65  else if (Val3 < Val1) return Val1;
66  else return Val3;
67  } else {
68  if (Val1 < Val3) return Val1;
69  else if (Val3 < Val2) return Val2;
70  else return Val3;
71  }
72  }
template<class T >
static const T& TMath::Mn ( const T &  Val1,
const T &  Val2,
const T &  Val3 
)
inlinestatic

Definition at line 51 of file xmath.h.

51  {
52  if(Val1 < Val2) {
53  if (Val1 < Val3) return Val1;
54  else return Val3;
55  } else {
56  if (Val2 < Val3) return Val2;
57  else return Val3;
58  }
59  }
template<class T >
static const T& TMath::Mx ( const T &  Val1,
const T &  Val2,
const T &  Val3 
)
inlinestatic

Definition at line 40 of file xmath.h.

40  {
41  if (Val1 > Val2) {
42  if (Val1 > Val3) return Val1;
43  else return Val3;
44  } else {
45  if (Val2 > Val3) return Val2;
46  else return Val3;
47  }
48  }
static uint TMath::Pow2 ( const int &  pow)
inlinestatic

Definition at line 24 of file xmath.h.

Referenced by TGraphEnumUtils::GraphId().

24 {return uint(1u<<pow);}
unsigned int uint
Definition: bd.h:11

Here is the caller graph for this function:

static double TMath::Power ( const double &  Base,
const double &  Exponent 
)
inlinestatic

Definition at line 25 of file xmath.h.

Referenced by TSnap::GenBaraHierar(), TKroneckerLL::GetFullGraphLL(), and TNIBs::UpdateDiff().

25  {
26  return exp(log(Base)*Exponent);}

Here is the caller graph for this function:

static double TMath::Round ( const double &  Val,
int  Decs 
)
inlinestatic

Definition at line 18 of file xmath.h.

References Round().

18  {
19  const double pwr=pow(10.0, Decs); return Round(Val * pwr) / pwr;}
static double Round(const double &Val)
Definition: xmath.h:16

Here is the call graph for this function:

template<typename T >
static int TMath::Sign ( const T &  Val)
inlinestatic

Definition at line 29 of file xmath.h.

Referenced by TCesna::GradientForWK().

29 {return Val<0?-1:(Val>0?1:0);}

Here is the caller graph for this function:

static double TMath::Sqrt ( const double &  x)
inlinestatic

Definition at line 13 of file xmath.h.

References IAssert.

13 {IAssert(!(x<0.0)); return sqrt(x);}
#define IAssert(Cond)
Definition: bd.h:262

Member Data Documentation

double TMath::E =2.71828182845904523536
static

Definition at line 7 of file xmath.h.

Referenced by TExpBi::TExpBi().

double TMath::LogOf2 =log(double(2))
static

Definition at line 9 of file xmath.h.

Referenced by TSpecFunc::Entropy(), and Log2().

double TMath::Pi =3.14159265358979323846
static

The documentation for this class was generated from the following files: