SNAP Library 2.2, User Reference  2014-03-11 19:15:55
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
TVVec< TVal > Class Template Reference

#include <ds.h>

List of all members.

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 3100 of file ds.h.


Constructor & Destructor Documentation

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

Definition at line 3105 of file ds.h.

: XDim(), YDim(), ValV(){}
template<class TVal>
TVVec< TVal >::TVVec ( const TVVec< TVal > &  Vec) [inline]

Definition at line 3106 of file ds.h.

                         :
    XDim(Vec.XDim), YDim(Vec.YDim), ValV(Vec.ValV){}
template<class TVal>
TVVec< TVal >::TVVec ( const int &  _XDim,
const int &  _YDim 
) [inline]

Definition at line 3108 of file ds.h.

                                           :
    XDim(), YDim(), ValV(){Gen(_XDim, _YDim);}
template<class TVal>
TVVec< TVal >::TVVec ( const TVec< TVal > &  _ValV,
const int &  _XDim,
const int &  _YDim 
) [inline, explicit]

Definition at line 3110 of file ds.h.

                                                                             :
    XDim(_XDim), YDim(_YDim), ValV(_ValV){ IAssert(ValV.Len()==XDim*YDim); }
template<class TVal>
TVVec< TVal >::TVVec ( TSIn SIn) [inline, explicit]

Definition at line 3112 of file ds.h.

{Load(SIn);}

Member Function Documentation

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

Definition at line 3221 of file ds.h.

                         {
  TVVec<TVal> NewVVec(XDim+1, YDim);
  NewVVec.CopyFrom(*this);
  *this=NewVVec;
}
template<class TVal >
void TVVec< TVal >::AddYDim ( )

Definition at line 3228 of file ds.h.

                         {
  TVVec<TVal> NewVVec(XDim, YDim+1);
  NewVVec.CopyFrom(*this);
  *this=NewVVec;
}
template<class TVal>
const TVal& TVVec< TVal >::At ( const int &  X,
const int &  Y 
) const [inline]

Definition at line 3133 of file ds.h.

                                                   {
    Assert((0<=X)&&(X<int(XDim))&&(0<=Y)&&(Y<int(YDim)));
    return ValV[X*YDim+Y];}
template<class TVal>
TVal& TVVec< TVal >::At ( const int &  X,
const int &  Y 
) [inline]

Definition at line 3136 of file ds.h.

                                      {
    Assert((0<=X)&&(X<int(XDim))&&(0<=Y)&&(Y<int(YDim)));
    return ValV[X*YDim+Y];}
template<class TVal>
void TVVec< TVal >::Clr ( ) [inline]

Definition at line 3123 of file ds.h.

{XDim=0; YDim=0; ValV.Clr();}
template<class TVal>
void TVVec< TVal >::CopyFrom ( const TVVec< TVal > &  VVec)

Definition at line 3210 of file ds.h.

                                                 {
  int CopyXDim=TInt::GetMn(GetXDim(), VVec.GetXDim());
  int CopyYDim=TInt::GetMn(GetYDim(), VVec.GetYDim());
  for (int X=0; X<CopyXDim; X++){
    for (int Y=0; Y<CopyYDim; Y++){
      At(X, Y)=VVec.At(X, Y);
    }
  }
}
template<class TVal >
void TVVec< TVal >::DelX ( const int &  X)

Definition at line 3235 of file ds.h.

                                  {
  TVVec<TVal> NewVVec(XDim-1, YDim);
  for (int Y=0; Y<YDim; Y++){
    for (int LX=0; LX<X; LX++){
      NewVVec.At(LX, Y)=At(LX, Y);}
    for (int RX=X+1; RX<XDim; RX++){
      NewVVec.At(RX-1, Y)=At(RX, Y);}
  }
  *this=NewVVec;
}
template<class TVal >
void TVVec< TVal >::DelY ( const int &  Y)

Definition at line 3247 of file ds.h.

                                  {
  TVVec<TVal> NewVVec(XDim, YDim-1);
  for (int X=0; X<XDim; X++){
    for (int LY=0; LY<Y; LY++){
      NewVVec.At(X, LY)=At(X, LY);}
    for (int RY=Y+1; RY<YDim; RY++){
      NewVVec.At(X, RY-1)=At(X, RY);}
  }
  *this=NewVVec;
}
template<class TVal>
bool TVVec< TVal >::Empty ( ) const [inline]

Definition at line 3122 of file ds.h.

{return ValV.Len()==0;}
template<class TVal>
void TVVec< TVal >::Gen ( const int &  _XDim,
const int &  _YDim 
) [inline]

Definition at line 3124 of file ds.h.

                                              {
    Assert((_XDim>=0)&&(_YDim>=0));
    XDim=_XDim; YDim=_YDim; ValV.Gen(XDim*YDim);}
template<class TVal>
TVec<TVal>& TVVec< TVal >::Get1DVec ( ) [inline]

Definition at line 3131 of file ds.h.

{return ValV;}
template<class TVal>
void TVVec< TVal >::GetCol ( const int &  ColN,
TVec< TVal > &  Vec 
) const

Definition at line 3267 of file ds.h.

                                                               {
  Vec.Gen(GetRows(), 0);
  for (int row = 0; row < GetRows(); row++) {
    Vec.Add(At(row, ColN));
  }
}
template<class TVal>
int TVVec< TVal >::GetCols ( ) const [inline]

Definition at line 3130 of file ds.h.

{return YDim;}
template<class TVal >
void TVVec< TVal >::GetMxValXY ( int &  X,
int &  Y 
) const

Definition at line 3203 of file ds.h.

                                                 {
  int MxValN=ValV.GetMxValN();
  Y=MxValN%YDim;
  X=MxValN/YDim;
}
template<class TVal>
void TVVec< TVal >::GetRow ( const int &  RowN,
TVec< TVal > &  Vec 
) const

Definition at line 3259 of file ds.h.

                                                               {
  Vec.Gen(GetCols(), 0);
  for (int col = 0; col < GetCols(); col++) {
    Vec.Add(At(RowN, col));
  }
}
template<class TVal>
int TVVec< TVal >::GetRows ( ) const [inline]

Definition at line 3129 of file ds.h.

{return XDim;}
template<class TVal>
int TVVec< TVal >::GetXDim ( ) const [inline]

Definition at line 3127 of file ds.h.

{return XDim;}
template<class TVal>
TVal TVVec< TVal >::GetXY ( const int &  X,
const int &  Y 
) const [inline]

Definition at line 3150 of file ds.h.

                                               {
    Assert((0<=X)&&(X<int(XDim))&&(0<=Y)&&(Y<int(YDim)));
    return ValV[X*YDim+Y];}
template<class TVal>
int TVVec< TVal >::GetYDim ( ) const [inline]

Definition at line 3128 of file ds.h.

{return YDim;}
template<class TVal>
void TVVec< TVal >::Load ( TSIn SIn) [inline]

Definition at line 3113 of file ds.h.

{XDim.Load(SIn); YDim.Load(SIn); ValV.Load(SIn);}
template<class TVal>
TVal& TVVec< TVal >::operator() ( const int &  X,
const int &  Y 
) [inline]

Definition at line 3139 of file ds.h.

                                              {
    return At(X, Y);}
template<class TVal>
const TVal& TVVec< TVal >::operator() ( const int &  X,
const int &  Y 
) const [inline]

Definition at line 3141 of file ds.h.

                                                           {
    return At(X, Y);}
template<class TVal>
TVVec<TVal>& TVVec< TVal >::operator= ( const TVVec< TVal > &  Vec) [inline]

Definition at line 3117 of file ds.h.

                                                {
    if (this!=&Vec){XDim=Vec.XDim; YDim=Vec.YDim; ValV=Vec.ValV;} return *this;}
template<class TVal>
bool TVVec< TVal >::operator== ( const TVVec< TVal > &  Vec) const [inline]

Definition at line 3119 of file ds.h.

                                          {
    return (XDim==Vec.XDim)&&(YDim==Vec.YDim)&&(ValV==Vec.ValV);}
template<class TVal>
void TVVec< TVal >::PutAll ( const TVal &  Val) [inline]

Definition at line 3145 of file ds.h.

{ValV.PutAll(Val);}
template<class TVal>
void TVVec< TVal >::PutX ( const int &  X,
const TVal &  Val 
) [inline]

Definition at line 3146 of file ds.h.

                                          {
    for (int Y=0; Y<int(YDim); Y++){At(X, Y)=Val;}}
template<class TVal>
void TVVec< TVal >::PutXY ( const int &  X,
const int &  Y,
const TVal &  Val 
) [inline]

Definition at line 3144 of file ds.h.

{At(X, Y)=Val;}
template<class TVal>
void TVVec< TVal >::PutY ( const int &  Y,
const TVal &  Val 
) [inline]

Definition at line 3148 of file ds.h.

                                          {
    for (int X=0; X<int(XDim); X++){At(X, Y)=Val;}}
template<class TVal>
void TVVec< TVal >::Save ( TSOut SOut) const [inline]

Definition at line 3114 of file ds.h.

                               {
    XDim.Save(SOut); YDim.Save(SOut); ValV.Save(SOut);}
template<class TVal >
void TVVec< TVal >::ShuffleX ( TRnd Rnd)

Definition at line 3193 of file ds.h.

                                   {
  for (int X=0; X<XDim-1; X++){SwapX(X, X+Rnd.GetUniDevInt(XDim-X));}
}
template<class TVal >
void TVVec< TVal >::ShuffleY ( TRnd Rnd)

Definition at line 3198 of file ds.h.

                                   {
  for (int Y=0; Y<YDim-1; Y++){SwapY(Y, Y+Rnd.GetUniDevInt(YDim-Y));}
}
template<class TVal>
void TVVec< TVal >::Swap ( TVVec< TVal > &  Vec)

Definition at line 3184 of file ds.h.

                                      {  //J:
  if (this!=&Vec){
    ::Swap(XDim, Vec.XDim);
    ::Swap(YDim, Vec.YDim);
    ValV.Swap(Vec.ValV);
  }
}
template<class TVal >
void TVVec< TVal >::SwapX ( const int &  X1,
const int &  X2 
)

Definition at line 3172 of file ds.h.

                                                   {
  for (int Y=0; Y<int(YDim); Y++){
    TVal Val=At(X1, Y); At(X1, Y)=At(X2, Y); At(X2, Y)=Val;}
}
template<class TVal >
void TVVec< TVal >::SwapY ( const int &  Y1,
const int &  Y2 
)

Definition at line 3178 of file ds.h.

                                                   {
  for (int X=0; X<int(XDim); X++){
    TVal Val=At(X, Y1); At(X, Y1)=At(X, Y2); At(X, Y2)=Val;}
}

Member Data Documentation

template<class TVal>
TVec<TVal> TVVec< TVal >::ValV [private]

Definition at line 3103 of file ds.h.

template<class TVal>
TInt TVVec< TVal >::XDim [private]

Definition at line 3102 of file ds.h.

template<class TVal>
TInt TVVec< TVal >::YDim [private]

Definition at line 3102 of file ds.h.


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