Skip to content

Commit

Permalink
templatized the type of Vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel committed Jul 3, 2024
1 parent ff90bb6 commit eb9eab4
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 124 deletions.
8 changes: 4 additions & 4 deletions src/tools/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class Communicator {
/// Init from reference
template <typename T> explicit Data(T&p): pointer(&p), size(1), nbytes(sizeof(T)), type(getMPIType<T>()) {}
/// Init from pointer to VectorGeneric
template <unsigned n> explicit Data(VectorGeneric<n> *p,int s): pointer(p), size(n*s), nbytes(sizeof(double)), type(getMPIType<double>()) {}
template <typename T, unsigned n> explicit Data(VectorTyped<T,n> *p,int s): pointer(p), size(n*s), nbytes(sizeof(T)), type(getMPIType<T>()) {}
/// Init from reference to VectorGeneric
template <unsigned n> explicit Data(VectorGeneric<n> &p): pointer(&p), size(n), nbytes(sizeof(double)), type(getMPIType<double>()) {}
template <typename T, unsigned n> explicit Data(VectorTyped<T,n> &p): pointer(&p), size(n), nbytes(sizeof(T)), type(getMPIType<T>()) {}
/// Init from pointer to TensorGeneric
template <unsigned n,unsigned m> explicit Data(TensorGeneric<n,m> *p,int s): pointer(p), size(n*m*s), nbytes(sizeof(double)), type(getMPIType<double>()) {}
/// Init from reference to TensorGeneric
Expand Down Expand Up @@ -104,8 +104,8 @@ class Communicator {
MPI_Datatype type;
template <typename T> explicit ConstData(const T*p,int s): pointer(p), size(s), nbytes(sizeof(T)), type(getMPIType<T>()) {}
template <typename T> explicit ConstData(const T&p): pointer(&p), size(1), nbytes(sizeof(T)), type(getMPIType<T>()) {}
template <unsigned n> explicit ConstData(const VectorGeneric<n> *p,int s): pointer(p), size(n*s), nbytes(sizeof(double)), type(getMPIType<double>()) {}
template <unsigned n> explicit ConstData(const VectorGeneric<n> &p): pointer(&p), size(n), nbytes(sizeof(double)), type(getMPIType<double>()) {}
template <typename T,unsigned n> explicit ConstData(const VectorTyped<T,n> *p,int s): pointer(p), size(n*s), nbytes(sizeof(T)), type(getMPIType<T>()) {}
template <typename T,unsigned n> explicit ConstData(const VectorTyped<T,n> &p): pointer(&p), size(n), nbytes(sizeof(T)), type(getMPIType<T>()) {}
template <unsigned n,unsigned m> explicit ConstData(const TensorGeneric<n,m> *p,int s): pointer(p), size(n*m*s), nbytes(sizeof(double)), type(getMPIType<double>()) {}
template <unsigned n,unsigned m> explicit ConstData(const TensorGeneric<n,m> &p): pointer(&p), size(n*m), nbytes(sizeof(double)), type(getMPIType<double>()) {}
template <typename T> explicit ConstData(const std::vector<T>&v) {
Expand Down
3 changes: 1 addition & 2 deletions src/tools/Tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,4 @@ static_assert(sizeof(Tensor)==9*sizeof(double), "code cannot work if this is not

}

#endif

#endif //__PLUMED_tools_Tensor_h
Loading

0 comments on commit eb9eab4

Please sign in to comment.