Skip to content
Snippets Groups Projects
Commit fd219ef9 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Simplified Communicator

Using .data() (C++11)
parent b97bc878
No related branches found
No related tags found
No related merge requests found
...@@ -80,8 +80,7 @@ class Communicator { ...@@ -80,8 +80,7 @@ class Communicator {
template <unsigned n,unsigned m> explicit Data(TensorGeneric<n,m> &p): pointer(&p), size(n*m), type(getMPIType<double>()) {} template <unsigned n,unsigned m> explicit Data(TensorGeneric<n,m> &p): pointer(&p), size(n*m), type(getMPIType<double>()) {}
/// Init from reference to std::vector /// Init from reference to std::vector
template <typename T> explicit Data(std::vector<T>&v) { template <typename T> explicit Data(std::vector<T>&v) {
if(v.size()>0) { Data d(&v[0],v.size()); pointer=d.pointer; size=d.size; type=d.type; } Data d(v.data(),v.size()); pointer=d.pointer; size=d.size; type=d.type;
else { pointer=NULL; size=0; }
} }
/// Init from reference to PLMD::Matrix /// Init from reference to PLMD::Matrix
template <typename T> explicit Data(Matrix<T>&m ) { template <typename T> explicit Data(Matrix<T>&m ) {
...@@ -107,8 +106,7 @@ class Communicator { ...@@ -107,8 +106,7 @@ class Communicator {
template <unsigned n,unsigned m> explicit ConstData(const TensorGeneric<n,m> *p,int s): pointer(p), size(n*m*s), type(getMPIType<double>()) {} template <unsigned n,unsigned m> explicit ConstData(const TensorGeneric<n,m> *p,int s): pointer(p), size(n*m*s), type(getMPIType<double>()) {}
template <unsigned n,unsigned m> explicit ConstData(const TensorGeneric<n,m> &p): pointer(&p), size(n*m), type(getMPIType<double>()) {} template <unsigned n,unsigned m> explicit ConstData(const TensorGeneric<n,m> &p): pointer(&p), size(n*m), type(getMPIType<double>()) {}
template <typename T> explicit ConstData(const std::vector<T>&v) { template <typename T> explicit ConstData(const std::vector<T>&v) {
if(v.size()>0) { ConstData d(&v[0],v.size()); pointer=d.pointer; size=d.size; type=d.type; } ConstData d(v.data(),v.size()); pointer=d.pointer; size=d.size; type=d.type;
else { pointer=NULL; size=0; }
} }
template <typename T> explicit ConstData(const Matrix<T>&m ) { template <typename T> explicit ConstData(const Matrix<T>&m ) {
if(m.nrows()*m.ncols()>0) { ConstData d(&m(0,0),m.nrows()*m.ncols()); pointer=d.pointer; size=d.size; type=d.type; } if(m.nrows()*m.ncols()>0) { ConstData d(&m(0,0),m.nrows()*m.ncols()); pointer=d.pointer; size=d.size; type=d.type; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment