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
TMAGNodeBern Class Reference

#include <mag.h>

Collaboration diagram for TMAGNodeBern:

Public Member Functions

 TMAGNodeBern ()
 
 TMAGNodeBern (const int &_Dim, const double &_Mu=0.5)
 
 TMAGNodeBern (const TFltV &_MuV)
 
 TMAGNodeBern (const TMAGNodeBern &Dist)
 
TMAGNodeBernoperator= (const TMAGNodeBern &Dist)
 
void SetMuV (const TFltV &_MuV)
 
const TFltVGetMuV () const
 
void SetMu (const int &Attr, const double &Prob)
 
double GetMu (const int &Attr) 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 MuV
 
TInt Dim
 

Detailed Description

Definition at line 88 of file mag.h.

Constructor & Destructor Documentation

TMAGNodeBern::TMAGNodeBern ( )
inline

Definition at line 95 of file mag.h.

95 : MuV(), Dim(-1) {}
TInt Dim
Definition: mag.h:93
TFltV MuV
Definition: mag.h:92
TMAGNodeBern::TMAGNodeBern ( const int &  _Dim,
const double &  _Mu = 0.5 
)
inline

Definition at line 96 of file mag.h.

References IAssert, MuV, and TVec< TVal, TSizeTy >::PutAll().

96 : MuV(_Dim), Dim(_Dim) { IAssert(_Mu >= 0.0 && _Mu <= 1.0); MuV.PutAll(_Mu); }
#define IAssert(Cond)
Definition: bd.h:262
TInt Dim
Definition: mag.h:93
TFltV MuV
Definition: mag.h:92
void PutAll(const TVal &Val)
Sets all elements of the vector to value Val.
Definition: ds.h:1229

Here is the call graph for this function:

TMAGNodeBern::TMAGNodeBern ( const TFltV _MuV)
inline

Definition at line 97 of file mag.h.

97 : MuV(_MuV), Dim(_MuV.Len()) {}
TInt Dim
Definition: mag.h:93
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TFltV MuV
Definition: mag.h:92
TMAGNodeBern::TMAGNodeBern ( const TMAGNodeBern Dist)
inline

Definition at line 98 of file mag.h.

98 : MuV(Dist.MuV), Dim(Dist.Dim) {}
TInt Dim
Definition: mag.h:93
TFltV MuV
Definition: mag.h:92

Member Function Documentation

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

Definition at line 250 of file mag.cpp.

References TVVec< TVal, TSizeTy >::At(), Dim, TVVec< TVal, TSizeTy >::Gen(), IAssert, MuV, and TVVec< TVal, TSizeTy >::PutAll().

250  {
251  IAssert(Dim > 0);
252  AttrVV.Gen(NNodes, Dim);
253  AttrVV.PutAll(0);
254 
255  for(int i = 0; i < NNodes; i++) {
256  for(int l = 0; l < Dim; l++) {
257  if((TMAGNodeBern::Rnd).GetUniDev() > MuV[l]) {
258  AttrVV.At(i, l) = 1;
259  }
260  }
261  }
262 }
#define IAssert(Cond)
Definition: bd.h:262
TInt Dim
Definition: mag.h:93
TFltV MuV
Definition: mag.h:92
void PutAll(const TVal &Val)
Definition: ds.h:2267
static TRnd Rnd
Definition: mag.h:90
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:

double TMAGNodeBern::GetMu ( const int &  Attr) const
inline

Definition at line 105 of file mag.h.

References MuV.

Referenced by TMAGFitBern::UpdateApxPhiMI(), TMAGFitBern::UpdateMu(), TMAGFitBern::UpdatePhi(), and TMAGFitBern::UpdatePhiMI().

105 { return MuV[Attr]; }
TFltV MuV
Definition: mag.h:92

Here is the caller graph for this function:

const TFltV& TMAGNodeBern::GetMuV ( ) const
inline

Definition at line 103 of file mag.h.

References MuV.

Referenced by TMAGFitBern::ComputeApxAdjLL(), TMAGFitBern::ComputeApxLL(), TMAGFitBern::ComputeJointAdjLL(), TMAGFitBern::ComputeJointOneLL(), TMAGFitBern::DoEMAlg(), TMAGFitBern::GetMuV(), and TMAGFitBern::UpdateAffMtxV().

103 { return MuV; }
TFltV MuV
Definition: mag.h:92

Here is the caller graph for this function:

void TMAGNodeBern::LoadTxt ( const TStr InFNm)

Definition at line 264 of file mag.cpp.

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

264  {
265  FILE *fp = fopen(InFNm.CStr(), "r");
266  IAssertR(fp != NULL, "File does not exist: " + InFNm);
267 
268  Dim = 0;
269  MuV.Gen(10, 0);
270 
271  char buf[128];
272  char *token;
273  TStr TokenStr;
274  TFlt Val;
275 
276  while(fgets(buf, sizeof(buf), fp) != NULL) {
277  token = strtok(buf, "&");
278  token = strtok(token, " \t");
279  TokenStr = TStr(token);
280  MuV.Add(TokenStr.GetFlt(Val));
281  }
282  Dim = MuV.Len();
283 
284  fclose(fp);
285 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
TInt Dim
Definition: mag.h:93
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
Definition: dt.h:1383
double GetFlt() const
Definition: dt.h:628
TFltV MuV
Definition: mag.h:92
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:

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

Definition at line 244 of file mag.cpp.

References Dim, and MuV.

244  {
245  MuV = Dist.MuV;
246  Dim = Dist.Dim;
247  return (*this);
248 }
TInt Dim
Definition: mag.h:93
TFltV MuV
Definition: mag.h:92
void TMAGNodeBern::SaveTxt ( TStrV OutStrV) const

Definition at line 287 of file mag.cpp.

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

287  {
288  OutStrV.Gen(Dim, 0);
289 
290  for(int i = 0; i < Dim; i++) {
291  OutStrV.Add(TStr::Fmt("%f", double(MuV[i])));
292  }
293 }
TInt Dim
Definition: mag.h:93
TFltV MuV
Definition: mag.h:92
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 TMAGNodeBern::SetMu ( const int &  Attr,
const double &  Prob 
)
inline

Definition at line 104 of file mag.h.

References IAssert, and MuV.

Referenced by TMAGFitBern::UpdateMu().

104 { IAssert(Prob >= 0.0 && Prob <= 1.0); MuV[Attr] = Prob; }
#define IAssert(Cond)
Definition: bd.h:262
TFltV MuV
Definition: mag.h:92

Here is the caller graph for this function:

void TMAGNodeBern::SetMuV ( const TFltV _MuV)
inline

Definition at line 102 of file mag.h.

References MuV.

Referenced by TMAGFitBern::SetMuV().

102 { MuV = _MuV; }
TFltV MuV
Definition: mag.h:92

Here is the caller graph for this function:

Member Data Documentation

TInt TMAGNodeBern::Dim
private

Definition at line 93 of file mag.h.

Referenced by AttrGen(), LoadTxt(), operator=(), and SaveTxt().

TFltV TMAGNodeBern::MuV
private

Definition at line 92 of file mag.h.

Referenced by AttrGen(), GetMu(), GetMuV(), LoadTxt(), operator=(), SaveTxt(), SetMu(), SetMuV(), and TMAGNodeBern().

TRnd TMAGNodeBern::Rnd = TRnd(0)
static

Definition at line 90 of file mag.h.

Referenced by TMAGFitBern::RandomInit().


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