PaCO++  0.05
CommMatrix.h
Go to the documentation of this file.
00001 #ifndef _COMMMATRIX_H
00002 #define _COMMMATRIX_H
00003 
00004 // represents a communication matrix
00005 
00006 class CommMatrix {
00007 
00008   unsigned _ssz;
00009   unsigned _rsz;
00010   long* _mat;
00011 
00012 public:
00013 
00014   CommMatrix(unsigned ssz=1, unsigned rsz=1);
00015   CommMatrix(CommMatrix* cm);
00016   ~CommMatrix();
00017 
00018   unsigned getSenderSize() const { return _ssz; }
00019   unsigned getReceiverSize() const { return _rsz; }
00020 
00021   void set(unsigned sid, unsigned rid, long val) {      _mat[sid*_rsz+rid] = val; }
00022   long get(unsigned sid, unsigned rid)   const { return _mat[sid*_rsz+rid]; }
00023   void add(unsigned sid, unsigned rid, long val) {      _mat[sid*_rsz+rid] += val; }
00024   void sub(unsigned sid, unsigned rid, long val) {      _mat[sid*_rsz+rid] -= val; }
00025 
00026   void dump() const;
00027 
00028 private:
00029   long* _get_mat() const { return _mat; }
00030 
00031 };
00032 
00033 
00034 #endif