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

#include <mag.h>

Collaboration diagram for TMAGNodeBern:

List of all members.

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

Definition at line 95 of file mag.h.

: MuV(), Dim(-1) {}
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 >::PutAll().

: MuV(_Dim), Dim(_Dim) {  IAssert(_Mu >= 0.0 && _Mu <= 1.0);  MuV.PutAll(_Mu);  }

Here is the call graph for this function:

TMAGNodeBern::TMAGNodeBern ( const TFltV _MuV) [inline]

Definition at line 97 of file mag.h.

: MuV(_MuV), Dim(_MuV.Len()) {}
TMAGNodeBern::TMAGNodeBern ( const TMAGNodeBern Dist) [inline]

Definition at line 98 of file mag.h.

: MuV(Dist.MuV), Dim(Dist.Dim) {}

Member Function Documentation

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

Definition at line 250 of file mag.cpp.

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

                                                            {
        IAssert(Dim > 0);
        AttrVV.Gen(NNodes, Dim);
        AttrVV.PutAll(0);
        
        for(int i = 0; i < NNodes; i++) {
                for(int l = 0; l < Dim; l++) {
                        if((TMAGNodeBern::Rnd).GetUniDev() > MuV[l]) {
                                AttrVV.At(i, l) = 1;
                        }
                }
        }
}

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().

{  return MuV[Attr];  }

Here is the caller graph for this function:

const TFltV& TMAGNodeBern::GetMuV ( ) const [inline]
void TMAGNodeBern::LoadTxt ( const TStr InFNm)

Definition at line 264 of file mag.cpp.

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

                                            {
        FILE *fp = fopen(InFNm.CStr(), "r");
        IAssertR(fp != NULL, "File does not exist: " + InFNm);

        Dim = 0;
        MuV.Gen(10, 0);

        char buf[128];
        char *token;
        TStr TokenStr;
        TFlt Val;

        while(fgets(buf, sizeof(buf), fp) != NULL) {
                token = strtok(buf, "&");
                token = strtok(token, " \t");
                TokenStr = TStr(token);
                MuV.Add(TokenStr.GetFlt(Val));
        }
        Dim = MuV.Len();

        fclose(fp);
}

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.

                                                              {
        MuV = Dist.MuV;
        Dim = Dist.Dim;
        return (*this);
}
void TMAGNodeBern::SaveTxt ( TStrV OutStrV) const

Definition at line 287 of file mag.cpp.

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

                                               {
        OutStrV.Gen(Dim, 0);

        for(int i = 0; i < Dim; i++) {
                OutStrV.Add(TStr::Fmt("%f", double(MuV[i])));
        }
}

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().

{  IAssert(Prob >= 0.0 && Prob <= 1.0);  MuV[Attr] = Prob;  }

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().

{  MuV = _MuV;  }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 93 of file mag.h.

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

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.


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