SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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
TMAGNodeBeta Class Reference

#include <mag.h>

Collaboration diagram for TMAGNodeBeta:

Public Member Functions

 TMAGNodeBeta ()
 
 TMAGNodeBeta (const int &_Dim, const double &Alpha=1, const double &Beta=1)
 
 TMAGNodeBeta (const TFltV &_AlphaV, const TFltV &_BetaV)
 
TMAGNodeBetaoperator= (const TMAGNodeBeta &Dist)
 
void SetBeta (const int &Attr, const double &Alpha, const double &Beta)
 
void GetBeta (const int &Attr, double &Alpha, double &Beta) const
 
void SetBetaV (const TFltV &_AlphaV, const TFltV &_BetaV)
 
void GetBetaV (TFltV &_AlphaV, TFltV &_BetaV) const
 
bool GetMuV (TFltV &_MuV) const
 
void LoadTxt (const TStr &InFNm)
 
void SaveTxt (TStrV &OutStrV) const
 
void AttrGen (TIntVV &AttrVV, const int &NNodes)
 

Static Public Attributes

static TRnd Rnd = TRnd(0)
 

Private Attributes

TFltV AlphaV
 
TFltV BetaV
 
TFltV MuV
 
TInt Dim
 
TBool Dirty
 

Detailed Description

Definition at line 115 of file mag.h.

Constructor & Destructor Documentation

TMAGNodeBeta::TMAGNodeBeta ( )
inline

Definition at line 125 of file mag.h.

125 : AlphaV(), BetaV(), MuV(), Dim(-1), Dirty(true) {}
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TFltV MuV
Definition: mag.h:121
TBool Dirty
Definition: mag.h:123
TFltV AlphaV
Definition: mag.h:119
TMAGNodeBeta::TMAGNodeBeta ( const int &  _Dim,
const double &  Alpha = 1,
const double &  Beta = 1 
)
inline

Definition at line 126 of file mag.h.

References AlphaV, BetaV, and TVec< TVal, TSizeTy >::PutAll().

126 : AlphaV(_Dim), BetaV(_Dim), MuV(_Dim), Dim(_Dim), Dirty(true) { AlphaV.PutAll(Alpha); BetaV.PutAll(Beta); }
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TFltV MuV
Definition: mag.h:121
TBool Dirty
Definition: mag.h:123
void PutAll(const TVal &Val)
Sets all elements of the vector to value Val.
Definition: ds.h:1229
TFltV AlphaV
Definition: mag.h:119

Here is the call graph for this function:

TMAGNodeBeta::TMAGNodeBeta ( const TFltV _AlphaV,
const TFltV _BetaV 
)
inline

Definition at line 127 of file mag.h.

References Dim, TVec< TVal, TSizeTy >::Gen(), IAssert, TVec< TVal, TSizeTy >::Len(), and MuV.

127 : AlphaV(_AlphaV), BetaV(_BetaV), Dirty(true) { IAssert(_AlphaV.Len() == _BetaV.Len()); Dim = _AlphaV.Len(); MuV.Gen(Dim); }
#define IAssert(Cond)
Definition: bd.h:262
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TFltV MuV
Definition: mag.h:121
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TBool Dirty
Definition: mag.h:123
TFltV AlphaV
Definition: mag.h:119
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523

Here is the call graph for this function:

Member Function Documentation

void TMAGNodeBeta::AttrGen ( TIntVV AttrVV,
const int &  NNodes 
)

Definition at line 323 of file mag.cpp.

References AlphaV, TVVec< TVal, TSizeTy >::At(), BetaV, Dim, Dirty, TVVec< TVal, TSizeTy >::Gen(), TRnd::GetGammaDev(), IAssert, MuV, and TVVec< TVal, TSizeTy >::PutAll().

323  {
324  IAssert(Dim > 0);
325  AttrVV.Gen(NNodes, Dim);
326  AttrVV.PutAll(0);
327 
328 // printf("AlphaV = %d, BetaV = %d, MuV = %d\n", AlphaV.Len(), BetaV.Len(), MuV.Len());
329 
330  for(int i = 0; i < NNodes; i++) {
331  for(int l = 0; l < Dim; l++) {
332  double x = TMAGNodeBeta::Rnd.GetGammaDev((int)AlphaV[l]);
333  double y = TMAGNodeBeta::Rnd.GetGammaDev((int)BetaV[l]);
334  MuV[l] = x / (x + y);
335  if((TMAGNodeBeta::Rnd).GetUniDev() > MuV[l]) {
336  AttrVV.At(i, l) = 1;
337  }
338  }
339  }
340  Dirty = false;
341 }
#define IAssert(Cond)
Definition: bd.h:262
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TFltV MuV
Definition: mag.h:121
static TRnd Rnd
Definition: mag.h:117
TBool Dirty
Definition: mag.h:123
double GetGammaDev(const int &Order)
Definition: dt.cpp:95
void PutAll(const TVal &Val)
Definition: ds.h:2267
TFltV AlphaV
Definition: mag.h:119
void Gen(const TSizeTy &_XDim, const TSizeTy &_YDim)
Definition: ds.h:2246
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2255

Here is the call graph for this function:

void TMAGNodeBeta::GetBeta ( const int &  Attr,
double &  Alpha,
double &  Beta 
) const
inline

Definition at line 132 of file mag.h.

References AlphaV, BetaV, Dim, and IAssert.

132 { IAssert(Attr < Dim); Alpha = AlphaV[Attr]; Beta = BetaV[Attr]; }
#define IAssert(Cond)
Definition: bd.h:262
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TFltV AlphaV
Definition: mag.h:119
void TMAGNodeBeta::GetBetaV ( TFltV _AlphaV,
TFltV _BetaV 
) const
inline

Definition at line 134 of file mag.h.

References AlphaV, and BetaV.

134 { _AlphaV = AlphaV; _BetaV = BetaV; }
TFltV BetaV
Definition: mag.h:120
TFltV AlphaV
Definition: mag.h:119
bool TMAGNodeBeta::GetMuV ( TFltV _MuV) const
inline

Definition at line 135 of file mag.h.

References Dirty, and MuV.

135 { if(!Dirty) { _MuV = MuV; } return Dirty; }
TFltV MuV
Definition: mag.h:121
TBool Dirty
Definition: mag.h:123
void TMAGNodeBeta::LoadTxt ( const TStr InFNm)

Definition at line 343 of file mag.cpp.

References TVec< TVal, TSizeTy >::Add(), AlphaV, BetaV, TStr::CStr(), Dim, TVec< TVal, TSizeTy >::Gen(), TStr::GetFlt(), and IAssertR.

343  {
344  FILE *fp = fopen(InFNm.CStr(), "r");
345  IAssertR(fp != NULL, "File does not exist: " + InFNm);
346 
347  Dim = 0;
348  AlphaV.Gen(10, 0);
349  BetaV.Gen(10, 0);
350 
351  char buf[128];
352  char *token;
353  TStr TokenStr;
354  TFlt Val;
355 
356  while(fgets(buf, sizeof(buf), fp) != NULL) {
357  token = strtok(buf, "&");
358 
359  token = strtok(token, " \t");
360  TokenStr = TStr(token);
361  AlphaV.Add(TokenStr.GetFlt(Val));
362 
363  token = strtok(NULL, " \t");
364  TokenStr = TStr(token);
365  BetaV.Add(TokenStr.GetFlt(Val));
366 
367  Dim++;
368  }
369 
370  fclose(fp);
371 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
Definition: dt.h:1383
double GetFlt() const
Definition: dt.h:628
TFltV AlphaV
Definition: mag.h:119
Definition: dt.h:412
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

Here is the call graph for this function:

TMAGNodeBeta & TMAGNodeBeta::operator= ( const TMAGNodeBeta Dist)

Definition at line 299 of file mag.cpp.

References AlphaV, BetaV, Dim, Dirty, and MuV.

299  {
300  AlphaV = Dist.AlphaV;
301  BetaV = Dist.BetaV;
302  Dim = Dist.Dim;
303  MuV = Dist.MuV;
304  Dirty = Dist.Dirty;
305  return (*this);
306 }
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TFltV MuV
Definition: mag.h:121
TBool Dirty
Definition: mag.h:123
TFltV AlphaV
Definition: mag.h:119
void TMAGNodeBeta::SaveTxt ( TStrV OutStrV) const

Definition at line 373 of file mag.cpp.

References TVec< TVal, TSizeTy >::Add(), AlphaV, BetaV, Dim, TStr::Fmt(), and TVec< TVal, TSizeTy >::Gen().

373  {
374  OutStrV.Gen(Dim, 0);
375 
376  for(int i = 0; i < Dim; i++) {
377  OutStrV.Add(TStr::Fmt("%f %f", double(AlphaV[i]), double(BetaV[i])));
378  }
379 }
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TFltV AlphaV
Definition: mag.h:119
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

Here is the call graph for this function:

void TMAGNodeBeta::SetBeta ( const int &  Attr,
const double &  Alpha,
const double &  Beta 
)

Definition at line 308 of file mag.cpp.

References AlphaV, BetaV, Dim, Dirty, and IAssert.

308  {
309  IAssert(Attr < Dim);
310  AlphaV[Attr] = Alpha;
311  BetaV[Attr] = Beta;
312  Dirty = true;
313 }
#define IAssert(Cond)
Definition: bd.h:262
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TBool Dirty
Definition: mag.h:123
TFltV AlphaV
Definition: mag.h:119
void TMAGNodeBeta::SetBetaV ( const TFltV _AlphaV,
const TFltV _BetaV 
)

Definition at line 315 of file mag.cpp.

References AlphaV, BetaV, Dim, Dirty, IAssert, and TVec< TVal, TSizeTy >::Len().

315  {
316  IAssert(_AlphaV.Len() == _BetaV.Len());
317  AlphaV = _AlphaV;
318  BetaV = _BetaV;
319  Dim = _AlphaV.Len();
320  Dirty = true;
321 }
#define IAssert(Cond)
Definition: bd.h:262
TFltV BetaV
Definition: mag.h:120
TInt Dim
Definition: mag.h:122
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TBool Dirty
Definition: mag.h:123
TFltV AlphaV
Definition: mag.h:119

Here is the call graph for this function:

Member Data Documentation

TFltV TMAGNodeBeta::AlphaV
private

Definition at line 119 of file mag.h.

Referenced by AttrGen(), GetBeta(), GetBetaV(), LoadTxt(), operator=(), SaveTxt(), SetBeta(), SetBetaV(), and TMAGNodeBeta().

TFltV TMAGNodeBeta::BetaV
private

Definition at line 120 of file mag.h.

Referenced by AttrGen(), GetBeta(), GetBetaV(), LoadTxt(), operator=(), SaveTxt(), SetBeta(), SetBetaV(), and TMAGNodeBeta().

TInt TMAGNodeBeta::Dim
private

Definition at line 122 of file mag.h.

Referenced by AttrGen(), GetBeta(), LoadTxt(), operator=(), SaveTxt(), SetBeta(), SetBetaV(), and TMAGNodeBeta().

TBool TMAGNodeBeta::Dirty
private

Definition at line 123 of file mag.h.

Referenced by AttrGen(), GetMuV(), operator=(), SetBeta(), and SetBetaV().

TFltV TMAGNodeBeta::MuV
private

Definition at line 121 of file mag.h.

Referenced by AttrGen(), GetMuV(), operator=(), and TMAGNodeBeta().

TRnd TMAGNodeBeta::Rnd = TRnd(0)
static

Definition at line 117 of file mag.h.


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