SNAP Library 3.0, Developer Reference  2016-07-20 17:56:49
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
TVVec< TVal > Class Template Reference

#include <ds.h>

Collaboration diagram for TVVec< TVal >:

Public Member Functions

 TVVec ()
 
 TVVec (const TVVec &Vec)
 
 TVVec (const int &_XDim, const int &_YDim)
 
 TVVec (const TVec< TVal > &_ValV, const int &_XDim, const int &_YDim)
 
 TVVec (TSIn &SIn)
 
void Load (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
TVVec< TVal > & operator= (const TVVec< TVal > &Vec)
 
bool operator== (const TVVec &Vec) const
 
bool Empty () const
 
void Clr ()
 
void Gen (const int &_XDim, const int &_YDim)
 
int GetXDim () const
 
int GetYDim () const
 
int GetRows () const
 
int GetCols () const
 
TVec< TVal > & Get1DVec ()
 
const TVal & At (const int &X, const int &Y) const
 
TVal & At (const int &X, const int &Y)
 
TVal & operator() (const int &X, const int &Y)
 
const TVal & operator() (const int &X, const int &Y) const
 
void PutXY (const int &X, const int &Y, const TVal &Val)
 
void PutAll (const TVal &Val)
 
void PutX (const int &X, const TVal &Val)
 
void PutY (const int &Y, const TVal &Val)
 
TVal GetXY (const int &X, const int &Y) const
 
void GetRow (const int &RowN, TVec< TVal > &Vec) const
 
void GetCol (const int &ColN, TVec< TVal > &Vec) const
 
void SwapX (const int &X1, const int &X2)
 
void SwapY (const int &Y1, const int &Y2)
 
void Swap (TVVec< TVal > &Vec)
 
void ShuffleX (TRnd &Rnd)
 
void ShuffleY (TRnd &Rnd)
 
void GetMxValXY (int &X, int &Y) const
 
void CopyFrom (const TVVec< TVal > &VVec)
 
void AddXDim ()
 
void AddYDim ()
 
void DelX (const int &X)
 
void DelY (const int &Y)
 

Private Attributes

TInt XDim
 
TInt YDim
 
TVec< TVal > ValV
 

Detailed Description

template<class TVal>
class TVVec< TVal >

Definition at line 2157 of file ds.h.

Constructor & Destructor Documentation

template<class TVal>
TVVec< TVal >::TVVec ( )
inline

Definition at line 2162 of file ds.h.

2162 : XDim(), YDim(), ValV(){}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
TVVec< TVal >::TVVec ( const TVVec< TVal > &  Vec)
inline

Definition at line 2163 of file ds.h.

2163  :
2164  XDim(Vec.XDim), YDim(Vec.YDim), ValV(Vec.ValV){}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
TVVec< TVal >::TVVec ( const int &  _XDim,
const int &  _YDim 
)
inline

Definition at line 2165 of file ds.h.

2165  :
2166  XDim(), YDim(), ValV(){Gen(_XDim, _YDim);}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
void Gen(const int &_XDim, const int &_YDim)
Definition: ds.h:2181
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
TVVec< TVal >::TVVec ( const TVec< TVal > &  _ValV,
const int &  _XDim,
const int &  _YDim 
)
inlineexplicit

Definition at line 2167 of file ds.h.

2167  :
2168  XDim(_XDim), YDim(_YDim), ValV(_ValV){ IAssert(ValV.Len()==XDim*YDim); }
#define IAssert(Cond)
Definition: bd.h:262
TInt YDim
Definition: ds.h:2159
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
TInt XDim
Definition: ds.h:2159
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
TVVec< TVal >::TVVec ( TSIn SIn)
inlineexplicit

Definition at line 2169 of file ds.h.

2169 {Load(SIn);}
void Load(TSIn &SIn)
Definition: ds.h:2170

Member Function Documentation

template<class TVal >
void TVVec< TVal >::AddXDim ( )

Definition at line 2278 of file ds.h.

References TVVec< TVal >::CopyFrom().

2278  {
2279  TVVec<TVal> NewVVec(XDim+1, YDim);
2280  NewVVec.CopyFrom(*this);
2281  *this=NewVVec;
2282 }
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
Definition: ds.h:2157

Here is the call graph for this function:

template<class TVal >
void TVVec< TVal >::AddYDim ( )

Definition at line 2285 of file ds.h.

References TVVec< TVal >::CopyFrom().

2285  {
2286  TVVec<TVal> NewVVec(XDim, YDim+1);
2287  NewVVec.CopyFrom(*this);
2288  *this=NewVVec;
2289 }
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
Definition: ds.h:2157

Here is the call graph for this function:

template<class TVal>
const TVal& TVVec< TVal >::At ( const int &  X,
const int &  Y 
) const
inline

Definition at line 2190 of file ds.h.

Referenced by TMAGNodeSimple::AttrGen(), TMAGNodeBern::AttrGen(), TMAGNodeBeta::AttrGen(), CalcNonNegativeFactorization(), TMAGFitBern::ComputeJointAdjLL(), TMAGFitBern::ComputeJointLL(), TMAGFitBern::ComputeJointOneLL(), TVVec< TVal >::CopyFrom(), TMom::DefVV(), TVVec< TVal >::DelX(), TVVec< TVal >::DelY(), TMAGFitBern::DoEMAlg(), TMAGFitBern::DoEStepApxOneIter(), TMAGFitBern::DoEStepOneIter(), TLinAlg::Gemm(), TMAGParam< TNodeAttr >::GenAttrMAG(), TMAGParam< TNodeAttr >::GenMAG(), TStr::GetDChStr(), TMAGFitBern::GetInCoeff(), TMAGFitBern::GetOutCoeff(), TMAGFitBern::GetProbMu(), TMAGFitBern::GetProbPhi(), TSnap::GetSngVals(), TSnap::GetSngVec(), TLinReg::GetXV(), TSvd::GetXV(), TLogRegFit::Hessian(), TLinAlg::InverseSVD(), TMom::IsUsableVV(), TMom::NewVV(), TLinReg::NR_covsrt(), TLinReg::NR_gaussj(), TLinReg::NR_lfit(), TSvd::NR_svbksb(), TSvd::NR_svdcmp(), TSvd::NR_svdfit(), TSvd::NR_svdvar(), TVVec< TFlt >::operator()(), TLAMisc::PrintTFltVV(), TVVec< TFlt >::PutX(), TVVec< TFlt >::PutXY(), TVVec< TFlt >::PutY(), TMAGFitBern::RandomInit(), TSvd::Svd(), TGraphKey::TakeSig(), TLinAlg::Transpose(), TMAGFitBern::UpdateApxPhiMI(), TMAGFitBern::UpdateMu(), TMAGFitBern::UpdatePhi(), and TMAGFitBern::UpdatePhiMI().

2190  {
2191  Assert((0<=X)&&(X<int(XDim))&&(0<=Y)&&(Y<int(YDim)));
2192  return ValV[X*YDim+Y];}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
#define Assert(Cond)
Definition: bd.h:251
TVec< TVal > ValV
Definition: ds.h:2160

Here is the caller graph for this function:

template<class TVal>
TVal& TVVec< TVal >::At ( const int &  X,
const int &  Y 
)
inline

Definition at line 2193 of file ds.h.

2193  {
2194  Assert((0<=X)&&(X<int(XDim))&&(0<=Y)&&(Y<int(YDim)));
2195  return ValV[X*YDim+Y];}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
#define Assert(Cond)
Definition: bd.h:251
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
void TVVec< TVal >::Clr ( )
inline

Definition at line 2180 of file ds.h.

Referenced by TMAGFitBern::Clr(), TMAGFitBern::ComputeJointLL(), TMAGFitBern::DoEStep(), TLAMisc::LoadMatlabTFltVV(), and TMAGFitBern::UpdateAffMtxV().

2180 {XDim=0; YDim=0; ValV.Clr();}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:971
TVec< TVal > ValV
Definition: ds.h:2160

Here is the caller graph for this function:

template<class TVal>
void TVVec< TVal >::CopyFrom ( const TVVec< TVal > &  VVec)

Definition at line 2267 of file ds.h.

References TVVec< TVal >::At(), TInt::GetMn(), TVVec< TVal >::GetXDim(), and TVVec< TVal >::GetYDim().

Referenced by TVVec< TVal >::AddXDim(), and TVVec< TVal >::AddYDim().

2267  {
2268  int CopyXDim=TInt::GetMn(GetXDim(), VVec.GetXDim());
2269  int CopyYDim=TInt::GetMn(GetYDim(), VVec.GetYDim());
2270  for (int X=0; X<CopyXDim; X++){
2271  for (int Y=0; Y<CopyYDim; Y++){
2272  At(X, Y)=VVec.At(X, Y);
2273  }
2274  }
2275 }
int GetXDim() const
Definition: ds.h:2184
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1090
int GetYDim() const
Definition: ds.h:2185
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
void TVVec< TVal >::DelX ( const int &  X)

Definition at line 2292 of file ds.h.

References TVVec< TVal >::At().

Referenced by TSvd::Svd(), and TSvd::Svd1Based().

2292  {
2293  TVVec<TVal> NewVVec(XDim-1, YDim);
2294  for (int Y=0; Y<YDim; Y++){
2295  for (int LX=0; LX<X; LX++){
2296  NewVVec.At(LX, Y)=At(LX, Y);}
2297  for (int RX=X+1; RX<XDim; RX++){
2298  NewVVec.At(RX-1, Y)=At(RX, Y);}
2299  }
2300  *this=NewVVec;
2301 }
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
Definition: ds.h:2157
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
void TVVec< TVal >::DelY ( const int &  Y)

Definition at line 2304 of file ds.h.

References TVVec< TVal >::At().

Referenced by TSvd::Svd(), and TSvd::Svd1Based().

2304  {
2305  TVVec<TVal> NewVVec(XDim, YDim-1);
2306  for (int X=0; X<XDim; X++){
2307  for (int LY=0; LY<Y; LY++){
2308  NewVVec.At(X, LY)=At(X, LY);}
2309  for (int RY=Y+1; RY<YDim; RY++){
2310  NewVVec.At(X, RY-1)=At(X, RY);}
2311  }
2312  *this=NewVVec;
2313 }
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
Definition: ds.h:2157
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal>
bool TVVec< TVal >::Empty ( ) const
inline

Definition at line 2179 of file ds.h.

Referenced by TStr::GetDChStr().

2179 {return ValV.Len()==0;}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
TVec< TVal > ValV
Definition: ds.h:2160

Here is the caller graph for this function:

template<class TVal>
void TVVec< TVal >::Gen ( const int &  _XDim,
const int &  _YDim 
)
inline
template<class TVal>
TVec<TVal>& TVVec< TVal >::Get1DVec ( )
inline

Definition at line 2188 of file ds.h.

2188 {return ValV;}
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
void TVVec< TVal >::GetCol ( const int &  ColN,
TVec< TVal > &  Vec 
) const

Definition at line 2324 of file ds.h.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Gen().

Referenced by TSnap::GetEigVec(), TSnap::GetInvParticipRat(), and TSnap::GetSngVec().

2324  {
2325  Vec.Gen(GetRows(), 0);
2326  for (int row = 0; row < GetRows(); row++) {
2327  Vec.Add(At(row, ColN));
2328  }
2329 }
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:495
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
int GetRows() const
Definition: ds.h:2186
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
void TVVec< TVal >::GetMxValXY ( int &  X,
int &  Y 
) const

Definition at line 2260 of file ds.h.

2260  {
2261  int MxValN=ValV.GetMxValN();
2262  Y=MxValN%YDim;
2263  X=MxValN/YDim;
2264 }
TInt YDim
Definition: ds.h:2159
TVec< TVal > ValV
Definition: ds.h:2160
TSizeTy GetMxValN() const
Returns the position of the largest element in the vector.
Definition: ds.h:1514
template<class TVal>
void TVVec< TVal >::GetRow ( const int &  RowN,
TVec< TVal > &  Vec 
) const

Definition at line 2316 of file ds.h.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Gen().

Referenced by TMAGFitBern::UpdateApxPhiMI().

2316  {
2317  Vec.Gen(GetCols(), 0);
2318  for (int col = 0; col < GetCols(); col++) {
2319  Vec.Add(At(RowN, col));
2320  }
2321 }
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:495
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
int GetCols() const
Definition: ds.h:2187
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal>
int TVVec< TVal >::GetXDim ( ) const
inline
template<class TVal>
TVal TVVec< TVal >::GetXY ( const int &  X,
const int &  Y 
) const
inline

Definition at line 2207 of file ds.h.

2207  {
2208  Assert((0<=X)&&(X<int(XDim))&&(0<=Y)&&(Y<int(YDim)));
2209  return ValV[X*YDim+Y];}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
#define Assert(Cond)
Definition: bd.h:251
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
void TVVec< TVal >::Load ( TSIn SIn)
inline

Definition at line 2170 of file ds.h.

Referenced by TVVec< TFlt >::TVVec().

2170 {XDim.Load(SIn); YDim.Load(SIn); ValV.Load(SIn);}
TInt YDim
Definition: ds.h:2159
void Load(TSIn &SIn)
Definition: ds.h:895
TInt XDim
Definition: ds.h:2159
void Load(TSIn &SIn)
Definition: dt.h:1059
TVec< TVal > ValV
Definition: ds.h:2160

Here is the caller graph for this function:

template<class TVal>
TVal& TVVec< TVal >::operator() ( const int &  X,
const int &  Y 
)
inline

Definition at line 2196 of file ds.h.

2196  {
2197  return At(X, Y);}
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190
template<class TVal>
const TVal& TVVec< TVal >::operator() ( const int &  X,
const int &  Y 
) const
inline

Definition at line 2198 of file ds.h.

2198  {
2199  return At(X, Y);}
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190
template<class TVal>
TVVec<TVal>& TVVec< TVal >::operator= ( const TVVec< TVal > &  Vec)
inline

Definition at line 2174 of file ds.h.

2174  {
2175  if (this!=&Vec){XDim=Vec.XDim; YDim=Vec.YDim; ValV=Vec.ValV;} return *this;}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
bool TVVec< TVal >::operator== ( const TVVec< TVal > &  Vec) const
inline

Definition at line 2176 of file ds.h.

2176  {
2177  return (XDim==Vec.XDim)&&(YDim==Vec.YDim)&&(ValV==Vec.ValV);}
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal>
void TVVec< TVal >::PutAll ( const TVal &  Val)
inline

Definition at line 2202 of file ds.h.

Referenced by TMAGNodeSimple::AttrGen(), TMAGNodeBern::AttrGen(), TMAGNodeBeta::AttrGen(), TMAGFitBern::ComputeMI(), TMAGFitBern::DoEStepApxOneIter(), TMAGFitBern::Init(), TMAGFitBern::RandomInit(), TMAGFitBern::SetPhiVV(), TMAGFitBern::UpdateApxPhiMI(), and TMAGFitBern::UpdatePhiMI().

2202 {ValV.PutAll(Val);}
void PutAll(const TVal &Val)
Sets all elements of the vector to value Val.
Definition: ds.h:1166
TVec< TVal > ValV
Definition: ds.h:2160

Here is the caller graph for this function:

template<class TVal>
void TVVec< TVal >::PutX ( const int &  X,
const TVal &  Val 
)
inline

Definition at line 2203 of file ds.h.

2203  {
2204  for (int Y=0; Y<int(YDim); Y++){At(X, Y)=Val;}}
TInt YDim
Definition: ds.h:2159
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190
template<class TVal>
void TVVec< TVal >::PutXY ( const int &  X,
const int &  Y,
const TVal &  Val 
)
inline

Definition at line 2201 of file ds.h.

2201 {At(X, Y)=Val;}
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190
template<class TVal>
void TVVec< TVal >::PutY ( const int &  Y,
const TVal &  Val 
)
inline

Definition at line 2205 of file ds.h.

Referenced by TMAGFitBern::SetPhiVV().

2205  {
2206  for (int X=0; X<int(XDim); X++){At(X, Y)=Val;}}
TInt XDim
Definition: ds.h:2159
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190

Here is the caller graph for this function:

template<class TVal>
void TVVec< TVal >::Save ( TSOut SOut) const
inline

Definition at line 2171 of file ds.h.

2171  {
2172  XDim.Save(SOut); YDim.Save(SOut); ValV.Save(SOut);}
TInt YDim
Definition: ds.h:2159
void Save(TSOut &SOut) const
Definition: dt.h:1060
TInt XDim
Definition: ds.h:2159
void Save(TSOut &SOut) const
Definition: ds.h:903
TVec< TVal > ValV
Definition: ds.h:2160
template<class TVal >
void TVVec< TVal >::ShuffleX ( TRnd Rnd)

Definition at line 2250 of file ds.h.

References TRnd::GetUniDevInt().

2250  {
2251  for (int X=0; X<XDim-1; X++){SwapX(X, X+Rnd.GetUniDevInt(XDim-X));}
2252 }
TInt XDim
Definition: ds.h:2159
void SwapX(const int &X1, const int &X2)
Definition: ds.h:2229
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39

Here is the call graph for this function:

template<class TVal >
void TVVec< TVal >::ShuffleY ( TRnd Rnd)

Definition at line 2255 of file ds.h.

References TRnd::GetUniDevInt().

2255  {
2256  for (int Y=0; Y<YDim-1; Y++){SwapY(Y, Y+Rnd.GetUniDevInt(YDim-Y));}
2257 }
TInt YDim
Definition: ds.h:2159
void SwapY(const int &Y1, const int &Y2)
Definition: ds.h:2235
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39

Here is the call graph for this function:

template<class TVal>
void TVVec< TVal >::Swap ( TVVec< TVal > &  Vec)

Definition at line 2241 of file ds.h.

References Swap(), TVVec< TVal >::ValV, TVVec< TVal >::XDim, and TVVec< TVal >::YDim.

2241  { //J:
2242  if (this!=&Vec){
2243  ::Swap(XDim, Vec.XDim);
2244  ::Swap(YDim, Vec.YDim);
2245  ValV.Swap(Vec.ValV);
2246  }
2247 }
TInt YDim
Definition: ds.h:2159
TInt XDim
Definition: ds.h:2159
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec.
Definition: ds.h:1047
TVec< TVal > ValV
Definition: ds.h:2160
void Swap(TVVec< TVal > &Vec)
Definition: ds.h:2241

Here is the call graph for this function:

template<class TVal >
void TVVec< TVal >::SwapX ( const int &  X1,
const int &  X2 
)

Definition at line 2229 of file ds.h.

2229  {
2230  for (int Y=0; Y<int(YDim); Y++){
2231  TVal Val=At(X1, Y); At(X1, Y)=At(X2, Y); At(X2, Y)=Val;}
2232 }
TInt YDim
Definition: ds.h:2159
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190
template<class TVal >
void TVVec< TVal >::SwapY ( const int &  Y1,
const int &  Y2 
)

Definition at line 2235 of file ds.h.

2235  {
2236  for (int X=0; X<int(XDim); X++){
2237  TVal Val=At(X, Y1); At(X, Y1)=At(X, Y2); At(X, Y2)=Val;}
2238 }
TInt XDim
Definition: ds.h:2159
const TVal & At(const int &X, const int &Y) const
Definition: ds.h:2190

Member Data Documentation


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