SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
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.

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

Definition at line 20 of file xmath.h.

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

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.

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.

83  {
84  return Val >= -Eps && Val <= Eps;}
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.

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
static double TMath::Log ( const double &  Val)
inlinestatic

Definition at line 14 of file xmath.h.

14 {return log(Val);}
static double TMath::Log2 ( const double &  Val)
inlinestatic

Definition at line 15 of file xmath.h.

15 {return log(Val)/LogOf2;}
static double LogOf2
Definition: xmath.h:9
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 &  LVal,
const T &  RVal 
)
inlinestatic

Definition at line 36 of file xmath.h.

36  {
37  return LVal < RVal ? LVal : RVal;}
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 &  LVal,
const T &  RVal 
)
inlinestatic

Definition at line 32 of file xmath.h.

32  {
33  return LVal > RVal ? LVal : RVal;}
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.

24 {return uint(1u<<pow);}
unsigned int uint
Definition: bd.h:11
static double TMath::Power ( const double &  Base,
const double &  Exponent 
)
inlinestatic

Definition at line 25 of file xmath.h.

25  {
26  return exp(log(Base)*Exponent);}
static double TMath::Round ( const double &  Val)
inlinestatic

Definition at line 16 of file xmath.h.

16  {
17  return (Val>0)?floor(Val+0.5):ceil(Val-0.5);}
static double TMath::Round ( const double &  Val,
int  Decs 
)
inlinestatic

Definition at line 18 of file xmath.h.

18  {
19  const double pwr=pow(10.0, Decs); return Round(Val * pwr) / pwr;}
static double Round(const double &Val)
Definition: xmath.h:16
template<typename T >
static int TMath::Sign ( const T &  Val)
inlinestatic

Definition at line 29 of file xmath.h.

29 {return Val<0?-1:(Val>0?1:0);}
static double TMath::Sqr ( const double &  x)
inlinestatic

Definition at line 12 of file xmath.h.

12 {return x*x;}
static double TMath::Sqrt ( const double &  x)
inlinestatic

Definition at line 13 of file xmath.h.

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.

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

Definition at line 9 of file xmath.h.

double TMath::Pi =3.14159265358979323846
static

Definition at line 8 of file xmath.h.


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