SNAP Library , Developer Reference  2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TMath Class Reference

#include <xmath.h>

List of all members.

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 
) [inline, static]

Definition at line 22 of file xmath.h.

References Fac().

                                               { // binomial coefficient
    return Fac(N)/(Fac(K)*Fac(N-K)); }

Here is the call graph for this function:

static int TMath::Fac ( const int &  Val) [inline, static]

Definition at line 20 of file xmath.h.

Referenced by Choose().

                                {
    if (Val<=1){return 1;} else {return Val*Fac(Val-1);}}

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 
) [inline, static]

Definition at line 75 of file xmath.h.

References IAssert.

                                                                  {
    IAssert(Mn <= Mx); return Val < Mn ? Mn : (Val > Mx ? Mx : Val);}
static double TMath::Inv ( const double &  x) [inline, static]

Definition at line 11 of file xmath.h.

References IAssert.

{IAssert(x!=0.0); return (1.0/x);}
template<class T >
static bool TMath::IsInEps ( const T &  Val,
const T &  Eps 
) [inline, static]

Definition at line 83 of file xmath.h.

Referenced by TKronMomentsFit::EstABC().

                                                  {
    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 
) [inline, static]

Definition at line 79 of file xmath.h.

References IAssert, and Mx().

                                                                {
    IAssert(Mn <= Mx); return Val >= Mn && Val <= Mx;}

Here is the call graph for this function:

static double TMath::Log ( const double &  Val) [inline, static]

Definition at line 14 of file xmath.h.

{return log(Val);}
static double TMath::Log2 ( const double &  Val) [inline, static]

Definition at line 15 of file xmath.h.

References LogOf2.

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

{return log(Val)/LogOf2;}

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 
) [inline, static]

Definition at line 62 of file xmath.h.

                                                                      {
    if (Val1 < Val2) {
      if (Val2 < Val3) return Val2;
      else if (Val3 < Val1) return Val1;
      else return Val3;
    } else {
      if (Val1 < Val3) return Val1;
      else if (Val3 < Val2)  return Val2;
      else return Val3;
    }
  }
template<class T >
static const T& TMath::Mn ( const T &  Val1,
const T &  Val2,
const T &  Val3 
) [inline, static]

Definition at line 51 of file xmath.h.

                                                                  {
    if(Val1 < Val2) {
      if (Val1 < Val3) return Val1;
      else return Val3;
    } else {
      if (Val2 < Val3) return Val2;
      else return Val3;
    }
  }
template<class T >
static const T& TMath::Mx ( const T &  Val1,
const T &  Val2,
const T &  Val3 
) [inline, static]

Definition at line 40 of file xmath.h.

                                                                  {
    if (Val1 > Val2) {
      if (Val1 > Val3) return Val1;
      else return Val3;
    } else {
      if (Val2 > Val3) return Val2;
      else return Val3;
    }
  }
static uint TMath::Pow2 ( const int &  pow) [inline, static]

Definition at line 24 of file xmath.h.

Referenced by TGraphEnumUtils::GraphId().

{return uint(1u<<pow);}

Here is the caller graph for this function:

static double TMath::Power ( const double &  Base,
const double &  Exponent 
) [inline, static]

Definition at line 25 of file xmath.h.

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

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

Here is the caller graph for this function:

static double TMath::Round ( const double &  Val,
int  Decs 
) [inline, static]

Definition at line 18 of file xmath.h.

References Round().

                                                   {
    const double pwr=pow(10.0, Decs); return Round(Val * pwr) / pwr;}

Here is the call graph for this function:

template<typename T >
static int TMath::Sign ( const T &  Val) [inline, static]

Definition at line 29 of file xmath.h.

{return Val<0?-1:(Val>0?1:0);}
static double TMath::Sqrt ( const double &  x) [inline, static]

Definition at line 13 of file xmath.h.

References IAssert.

{IAssert(!(x<0.0)); return sqrt(x);}

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: