SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TVVec< TVal, TSizeTy > Class Template Reference

#include <ds.h>

Public Member Functions

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

Private Attributes

TInt64 XDim
 
TInt64 YDim
 
TVec< TVal, TSizeTy > ValV
 

Detailed Description

template<class TVal, class TSizeTy = int>
class TVVec< TVal, TSizeTy >

Definition at line 2223 of file ds.h.

Constructor & Destructor Documentation

template<class TVal, class TSizeTy = int>
TVVec< TVal, TSizeTy >::TVVec ( )
inline

Definition at line 2228 of file ds.h.

2228 : XDim(), YDim(), ValV(){}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVVec< TVal, TSizeTy >::TVVec ( const TVVec< TVal, TSizeTy > &  Vec)
inline

Definition at line 2229 of file ds.h.

2229  :
2230  XDim(Vec.XDim), YDim(Vec.YDim), ValV(Vec.ValV){}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVVec< TVal, TSizeTy >::TVVec ( const TSizeTy &  _XDim,
const TSizeTy &  _YDim 
)
inline

Definition at line 2231 of file ds.h.

2231  :
2232  XDim(), YDim(), ValV(){Gen(_XDim, _YDim);}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
void Gen(const TSizeTy &_XDim, const TSizeTy &_YDim)
Definition: ds.h:2247
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVVec< TVal, TSizeTy >::TVVec ( const TVec< TVal, TSizeTy > &  _ValV,
const TSizeTy &  _XDim,
const TSizeTy &  _YDim 
)
inlineexplicit

Definition at line 2233 of file ds.h.

2233  :
2234  XDim(_XDim), YDim(_YDim), ValV(_ValV){ IAssert(ValV.Len()==XDim*YDim); }
#define IAssert(Cond)
Definition: bd.h:262
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVVec< TVal, TSizeTy >::TVVec ( TSIn SIn)
inlineexplicit

Definition at line 2235 of file ds.h.

2235 {Load(SIn);}
void Load(TSIn &SIn)
Definition: ds.h:2236

Member Function Documentation

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

Definition at line 2344 of file ds.h.

2344  {
2345  TVVec<TVal, TSizeTy> NewVVec(XDim+1, YDim);
2346  NewVVec.CopyFrom(*this);
2347  *this=NewVVec;
2348 }
Definition: ds.h:2223
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal , class TSizeTy >
void TVVec< TVal, TSizeTy >::AddYDim ( )

Definition at line 2351 of file ds.h.

2351  {
2352  TVVec<TVal, TSizeTy> NewVVec(XDim, YDim+1);
2353  NewVVec.CopyFrom(*this);
2354  *this=NewVVec;
2355 }
Definition: ds.h:2223
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
const TVal& TVVec< TVal, TSizeTy >::At ( const TSizeTy &  X,
const TSizeTy &  Y 
) const
inline

Definition at line 2256 of file ds.h.

2256  {
2257  Assert((0<=X)&&(X<TSizeTy(XDim))&&(0<=Y)&&(Y<TSizeTy(YDim)));
2258  return ValV[X*YDim+Y];}
#define Assert(Cond)
Definition: bd.h:251
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVal& TVVec< TVal, TSizeTy >::At ( const TSizeTy &  X,
const TSizeTy &  Y 
)
inline

Definition at line 2259 of file ds.h.

2259  {
2260  Assert((0<=X)&&(X<TSizeTy(XDim))&&(0<=Y)&&(Y<TSizeTy(YDim)));
2261  return ValV[X*YDim+Y];}
#define Assert(Cond)
Definition: bd.h:251
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
void TVVec< TVal, TSizeTy >::Clr ( )
inline

Definition at line 2246 of file ds.h.

2246 {XDim=0; YDim=0; ValV.Clr();}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy>
void TVVec< TVal, TSizeTy >::CopyFrom ( const TVVec< TVal, TSizeTy > &  VVec)

Definition at line 2333 of file ds.h.

2333  {
2334  TSizeTy CopyXDim = (GetXDim() < VVec.GetXDim()) ? GetXDim() : VVec.GetXDim();
2335  TSizeTy CopyYDim = (GetYDim() < VVec.GetYDim()) ? GetYDim() : VVec.GetYDim();
2336  for (TSizeTy X=0; X<CopyXDim; X++){
2337  for (TSizeTy Y=0; Y<CopyYDim; Y++){
2338  At(X, Y)=VVec.At(X, Y);
2339  }
2340  }
2341 }
TSizeTy GetYDim() const
Definition: ds.h:2251
TSizeTy GetXDim() const
Definition: ds.h:2250
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal , class TSizeTy>
void TVVec< TVal, TSizeTy >::DelX ( const TSizeTy &  X)

Definition at line 2358 of file ds.h.

2358  {
2359  TVVec<TVal, TSizeTy> NewVVec(XDim-1, YDim);
2360  for (TSizeTy Y=0; Y<YDim; Y++){
2361  for (TSizeTy LX=0; LX<X; LX++){
2362  NewVVec.At(LX, Y)=At(LX, Y);}
2363  for (TSizeTy RX=X+1; RX<XDim; RX++){
2364  NewVVec.At(RX-1, Y)=At(RX, Y);}
2365  }
2366  *this=NewVVec;
2367 }
Definition: ds.h:2223
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal , class TSizeTy>
void TVVec< TVal, TSizeTy >::DelY ( const TSizeTy &  Y)

Definition at line 2370 of file ds.h.

2370  {
2371  TVVec<TVal, TSizeTy> NewVVec(XDim, YDim-1);
2372  for (TSizeTy X=0; X<XDim; X++){
2373  for (TSizeTy LY=0; LY<Y; LY++){
2374  NewVVec.At(X, LY)=At(X, LY);}
2375  for (TSizeTy RY=Y+1; RY<YDim; RY++){
2376  NewVVec.At(X, RY-1)=At(X, RY);}
2377  }
2378  *this=NewVVec;
2379 }
Definition: ds.h:2223
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal, class TSizeTy = int>
bool TVVec< TVal, TSizeTy >::Empty ( ) const
inline

Definition at line 2245 of file ds.h.

2245 {return ValV.Len()==0;}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
template<class TVal, class TSizeTy = int>
void TVVec< TVal, TSizeTy >::Gen ( const TSizeTy &  _XDim,
const TSizeTy &  _YDim 
)
inline

Definition at line 2247 of file ds.h.

2247  {
2248  Assert((_XDim>=0)&&(_YDim>=0));
2249  XDim=_XDim; YDim=_YDim; ValV.Gen(XDim*YDim);}
#define Assert(Cond)
Definition: bd.h:251
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVec<TVal, TSizeTy>& TVVec< TVal, TSizeTy >::Get1DVec ( )
inline

Definition at line 2254 of file ds.h.

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

Definition at line 2390 of file ds.h.

2390  {
2391  Vec.Gen(GetRows(), 0);
2392  for (TSizeTy row = 0; row < GetRows(); row++) {
2393  Vec.Add(At(row, ColN));
2394  }
2395 }
TSizeTy GetRows() const
Definition: ds.h:2252
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
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal, class TSizeTy = int>
TSizeTy TVVec< TVal, TSizeTy >::GetCols ( ) const
inline

Definition at line 2253 of file ds.h.

2253 {return YDim;}
TInt64 YDim
Definition: ds.h:2225
template<class TVal , class TSizeTy>
void TVVec< TVal, TSizeTy >::GetMxValXY ( TSizeTy &  X,
TSizeTy &  Y 
) const

Definition at line 2326 of file ds.h.

2326  {
2327  TSizeTy MxValN=ValV.GetMxValN();
2328  Y=MxValN%YDim;
2329  X=MxValN/YDim;
2330 }
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy>
void TVVec< TVal, TSizeTy >::GetRow ( const TSizeTy &  RowN,
TVec< TVal, TSizeTy > &  Vec 
) const

Definition at line 2382 of file ds.h.

2382  {
2383  Vec.Gen(GetCols(), 0);
2384  for (TSizeTy col = 0; col < GetCols(); col++) {
2385  Vec.Add(At(RowN, col));
2386  }
2387 }
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
TSizeTy GetCols() const
Definition: ds.h:2253
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal, class TSizeTy = int>
TSizeTy TVVec< TVal, TSizeTy >::GetRows ( ) const
inline

Definition at line 2252 of file ds.h.

2252 {return XDim;}
TInt64 XDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TSizeTy TVVec< TVal, TSizeTy >::GetXDim ( ) const
inline

Definition at line 2250 of file ds.h.

2250 {return XDim;}
TInt64 XDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVal TVVec< TVal, TSizeTy >::GetXY ( const TSizeTy &  X,
const TSizeTy &  Y 
) const
inline

Definition at line 2273 of file ds.h.

2273  {
2274  Assert((0<=X)&&(X<TSizeTy(XDim))&&(0<=Y)&&(Y<TSizeTy(YDim)));
2275  return ValV[X*YDim+Y];}
#define Assert(Cond)
Definition: bd.h:251
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TSizeTy TVVec< TVal, TSizeTy >::GetYDim ( ) const
inline

Definition at line 2251 of file ds.h.

2251 {return YDim;}
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
void TVVec< TVal, TSizeTy >::Load ( TSIn SIn)
inline

Definition at line 2236 of file ds.h.

2236 {XDim.Load(SIn); YDim.Load(SIn); ValV.Load(SIn);}
void Load(TSIn &SIn)
Definition: dt.h:906
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
TVal& TVVec< TVal, TSizeTy >::operator() ( const TSizeTy &  X,
const TSizeTy &  Y 
)
inline

Definition at line 2262 of file ds.h.

2262  {
2263  return At(X, Y);}
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal, class TSizeTy = int>
const TVal& TVVec< TVal, TSizeTy >::operator() ( const TSizeTy &  X,
const TSizeTy &  Y 
) const
inline

Definition at line 2264 of file ds.h.

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

Definition at line 2240 of file ds.h.

2240  {
2241  if (this!=&Vec){XDim=Vec.XDim; YDim=Vec.YDim; ValV=Vec.ValV;} return *this;}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
bool TVVec< TVal, TSizeTy >::operator== ( const TVVec< TVal, TSizeTy > &  Vec) const
inline

Definition at line 2242 of file ds.h.

2242  {
2243  return (XDim==Vec.XDim)&&(YDim==Vec.YDim)&&(ValV==Vec.ValV);}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy = int>
void TVVec< TVal, TSizeTy >::PutAll ( const TVal &  Val)
inline

Definition at line 2268 of file ds.h.

2268 {ValV.PutAll(Val);}
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
template<class TVal, class TSizeTy = int>
void TVVec< TVal, TSizeTy >::PutX ( const TSizeTy &  X,
const TVal &  Val 
)
inline

Definition at line 2269 of file ds.h.

2269  {
2270  for (TSizeTy Y=0; Y<TSizeTy(YDim); Y++){At(X, Y)=Val;}}
TInt64 YDim
Definition: ds.h:2225
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal, class TSizeTy = int>
void TVVec< TVal, TSizeTy >::PutXY ( const TSizeTy &  X,
const TSizeTy &  Y,
const TVal &  Val 
)
inline

Definition at line 2267 of file ds.h.

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

Definition at line 2271 of file ds.h.

2271  {
2272  for (TSizeTy X=0; X<TSizeTy(XDim); X++){At(X, Y)=Val;}}
TInt64 XDim
Definition: ds.h:2225
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal, class TSizeTy = int>
void TVVec< TVal, TSizeTy >::Save ( TSOut SOut) const
inline

Definition at line 2237 of file ds.h.

2237  {
2238  XDim.Save(SOut); YDim.Save(SOut); ValV.Save(SOut);}
void Save(TSOut &SOut) const
Definition: dt.h:907
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal , class TSizeTy >
void TVVec< TVal, TSizeTy >::ShuffleX ( TRnd Rnd)

Definition at line 2316 of file ds.h.

2316  {
2317  for (TSizeTy X=0; X<XDim-1; X++){SwapX(X, X+Rnd.GetUniDevInt(XDim-X));}
2318 }
void SwapX(const TSizeTy &X1, const TSizeTy &X2)
Definition: ds.h:2295
TInt64 XDim
Definition: ds.h:2225
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39
template<class TVal , class TSizeTy >
void TVVec< TVal, TSizeTy >::ShuffleY ( TRnd Rnd)

Definition at line 2321 of file ds.h.

2321  {
2322  for (TSizeTy Y=0; Y<YDim-1; Y++){SwapY(Y, Y+Rnd.GetUniDevInt(YDim-Y));}
2323 }
void SwapY(const TSizeTy &Y1, const TSizeTy &Y2)
Definition: ds.h:2301
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39
TInt64 YDim
Definition: ds.h:2225
template<class TVal, class TSizeTy>
void TVVec< TVal, TSizeTy >::Swap ( TVVec< TVal, TSizeTy > &  Vec)

Definition at line 2307 of file ds.h.

2307  { //J:
2308  if (this!=&Vec){
2309  ::Swap(XDim, Vec.XDim);
2310  ::Swap(YDim, Vec.YDim);
2311  ValV.Swap(Vec.ValV);
2312  }
2313 }
void Swap(TVVec< TVal, TSizeTy > &Vec)
Definition: ds.h:2307
TVec< TVal, TSizeTy > ValV
Definition: ds.h:2226
TInt64 XDim
Definition: ds.h:2225
TInt64 YDim
Definition: ds.h:2225
template<class TVal , class TSizeTy>
void TVVec< TVal, TSizeTy >::SwapX ( const TSizeTy &  X1,
const TSizeTy &  X2 
)

Definition at line 2295 of file ds.h.

2295  {
2296  for (TSizeTy Y=0; Y<TSizeTy(YDim); Y++){
2297  TVal Val=At(X1, Y); At(X1, Y)=At(X2, Y); At(X2, Y)=Val;}
2298 }
TInt64 YDim
Definition: ds.h:2225
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
template<class TVal , class TSizeTy>
void TVVec< TVal, TSizeTy >::SwapY ( const TSizeTy &  Y1,
const TSizeTy &  Y2 
)

Definition at line 2301 of file ds.h.

2301  {
2302  for (TSizeTy X=0; X<TSizeTy(XDim); X++){
2303  TVal Val=At(X, Y1); At(X, Y1)=At(X, Y2); At(X, Y2)=Val;}
2304 }
TInt64 XDim
Definition: ds.h:2225
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256

Member Data Documentation

template<class TVal, class TSizeTy = int>
TVec<TVal, TSizeTy> TVVec< TVal, TSizeTy >::ValV
private

Definition at line 2226 of file ds.h.

template<class TVal, class TSizeTy = int>
TInt64 TVVec< TVal, TSizeTy >::XDim
private

Definition at line 2225 of file ds.h.

template<class TVal, class TSizeTy = int>
TInt64 TVVec< TVal, TSizeTy >::YDim
private

Definition at line 2225 of file ds.h.


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