PaCO++  0.05
CommMatrix.cc
Go to the documentation of this file.
1 #include "CommMatrix.h"
2 #include <stdlib.h>
3 #include <string.h>
4 #include <iostream>
5 
6 CommMatrix::CommMatrix(unsigned ssz, unsigned rsz)
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 }
15 
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 }
30 
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 }
40 
41 
42 void
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 }
void dump() const
Definition: CommMatrix.cc:43
unsigned getReceiverSize() const
Definition: CommMatrix.h:19
long * _get_mat() const
Definition: CommMatrix.h:29
CommMatrix(unsigned ssz=1, unsigned rsz=1)
Definition: CommMatrix.cc:6
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