PaCO++  0.05
CommMatrix Class Reference

#include <CommMatrix.h>

Collaboration diagram for CommMatrix:
Collaboration graph

Public Member Functions

void add (unsigned sid, unsigned rid, long val)
 
 CommMatrix (unsigned ssz=1, unsigned rsz=1)
 
 CommMatrix (CommMatrix *cm)
 
void dump () const
 
long get (unsigned sid, unsigned rid) const
 
unsigned getReceiverSize () const
 
unsigned getSenderSize () const
 
void set (unsigned sid, unsigned rid, long val)
 
void sub (unsigned sid, unsigned rid, long val)
 
 ~CommMatrix ()
 

Private Member Functions

long * _get_mat () const
 

Private Attributes

long * _mat
 
unsigned _rsz
 
unsigned _ssz
 

Detailed Description

Definition at line 6 of file CommMatrix.h.

Constructor & Destructor Documentation

◆ CommMatrix() [1/2]

CommMatrix::CommMatrix ( unsigned  ssz = 1,
unsigned  rsz = 1 
)

Definition at line 6 of file CommMatrix.cc.

References _mat, _rsz, and _ssz.

7 {
8  _ssz=ssz;
9  _rsz=rsz;
10  _mat=new long[ssz*rsz];
11 
12  std::cerr<<"[new] CommMatrix -- ssz: "<<_ssz<<" rsz:"<<_rsz<<std::endl;
13  std::cerr<<"[new] Alloc"<<(void*)_mat<<std::endl;
14 }
unsigned _rsz
Definition: CommMatrix.h:9
unsigned _ssz
Definition: CommMatrix.h:8
long * _mat
Definition: CommMatrix.h:10

◆ CommMatrix() [2/2]

CommMatrix::CommMatrix ( CommMatrix cm)

Definition at line 16 of file CommMatrix.cc.

References _get_mat(), _mat, _rsz, _ssz, getReceiverSize(), and getSenderSize().

17 {
18  _ssz=cm->getSenderSize();
19  _rsz=cm->getReceiverSize();
20  _mat=new long[_ssz*_rsz];
21 
22  std::cerr<<"[new/copy] Alloc"<<(void*)_mat<<std::endl;
23 
24  long* omat= cm->_get_mat();
25  memcpy(_mat, omat, sizeof(long)*_ssz*_rsz);
26 
27  std::cerr<<"[new/copy] CommMatrix -- ssz: "<<_ssz<<" rsz:"<<_rsz<<std::endl;
28 
29 }
unsigned getReceiverSize() const
Definition: CommMatrix.h:19
long * _get_mat() const
Definition: CommMatrix.h:29
unsigned _rsz
Definition: CommMatrix.h:9
unsigned getSenderSize() const
Definition: CommMatrix.h:18
unsigned _ssz
Definition: CommMatrix.h:8
long * _mat
Definition: CommMatrix.h:10
Here is the call graph for this function:

◆ ~CommMatrix()

CommMatrix::~CommMatrix ( )

Definition at line 31 of file CommMatrix.cc.

References _mat.

32 {
33  if (_mat) {
34  std::cerr<<"[del] free"<<(void*)_mat<<std::endl;
35  delete[] _mat;
36  }
37  _mat=NULL;
38  std::cerr<<"[del] CommMatrix"<<std::endl;
39 }
long * _mat
Definition: CommMatrix.h:10

Member Function Documentation

◆ _get_mat()

long* CommMatrix::_get_mat ( ) const
inlineprivate

Definition at line 29 of file CommMatrix.h.

References _mat.

Referenced by CommMatrix().

29 { return _mat; }
long * _mat
Definition: CommMatrix.h:10

◆ add()

void CommMatrix::add ( unsigned  sid,
unsigned  rid,
long  val 
)
inline

Definition at line 23 of file CommMatrix.h.

23 { _mat[sid*_rsz+rid] += val; }
unsigned _rsz
Definition: CommMatrix.h:9
long * _mat
Definition: CommMatrix.h:10

◆ dump()

void CommMatrix::dump ( ) const

Definition at line 43 of file CommMatrix.cc.

References _rsz, and _ssz.

Referenced by Controlled::readFromFile(), and sub().

44 {
45  std::cerr<<"[dump] CommMatrix -- ssz: "<<_ssz<<" rsz:"<<_rsz<<std::endl;
46  for(unsigned i=0;i<_ssz;i++) {
47  for(unsigned j=0;j<_rsz;j++) {
48  std::cerr << "[dump] "<<i<<" -> "<<j<<" : "<<this->get(i,j)<<std::endl;
49  }
50  }
51 }
unsigned _rsz
Definition: CommMatrix.h:9
unsigned _ssz
Definition: CommMatrix.h:8

◆ get()

long CommMatrix::get ( unsigned  sid,
unsigned  rid 
) const
inline

Definition at line 22 of file CommMatrix.h.

Referenced by Controlled::computePiecesToSend(), and Controlled::getClientData().

22 { return _mat[sid*_rsz+rid]; }
unsigned _rsz
Definition: CommMatrix.h:9
long * _mat
Definition: CommMatrix.h:10

◆ getReceiverSize()

unsigned CommMatrix::getReceiverSize ( ) const
inline

Definition at line 19 of file CommMatrix.h.

References _rsz.

Referenced by CommMatrix(), and Controlled::computePiecesToSend().

19 { return _rsz; }
unsigned _rsz
Definition: CommMatrix.h:9

◆ getSenderSize()

unsigned CommMatrix::getSenderSize ( ) const
inline

Definition at line 18 of file CommMatrix.h.

References _ssz.

Referenced by CommMatrix(), Controlled::computePiecesToSend(), and Controlled::getClientData().

18 { return _ssz; }
unsigned _ssz
Definition: CommMatrix.h:8

◆ set()

void CommMatrix::set ( unsigned  sid,
unsigned  rid,
long  val 
)
inline

Definition at line 21 of file CommMatrix.h.

Referenced by Controlled::readFromFile().

21 { _mat[sid*_rsz+rid] = val; }
unsigned _rsz
Definition: CommMatrix.h:9
long * _mat
Definition: CommMatrix.h:10

◆ sub()

void CommMatrix::sub ( unsigned  sid,
unsigned  rid,
long  val 
)
inline

Definition at line 24 of file CommMatrix.h.

References dump().

Referenced by Controlled::getClientData().

24 { _mat[sid*_rsz+rid] -= val; }
unsigned _rsz
Definition: CommMatrix.h:9
long * _mat
Definition: CommMatrix.h:10
Here is the call graph for this function:

Member Data Documentation

◆ _mat

long* CommMatrix::_mat
private

Definition at line 10 of file CommMatrix.h.

Referenced by _get_mat(), CommMatrix(), and ~CommMatrix().

◆ _rsz

unsigned CommMatrix::_rsz
private

Definition at line 9 of file CommMatrix.h.

Referenced by CommMatrix(), dump(), and getReceiverSize().

◆ _ssz

unsigned CommMatrix::_ssz
private

Definition at line 8 of file CommMatrix.h.

Referenced by CommMatrix(), dump(), and getSenderSize().


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