我有一个分布式 boost::numeric::ublas::vector distributed_boost_vector 我想在根处理器中收集整个分布式 boost vector 。 我正在尝试使用该功能:
template<typename T>
void gather(const communicator & comm, const T & in_value, T * out_values,
int root);
写作
boost::mpi::gather<boost::numeric::ublas::vector<double> >
(boost_comm, distributed_boost_vector, all_boost_vector, 0);
其中 all_boost_vector 是一个 boost::numeric::ublas::vector
我在编译时收到“no matching function for call”错误,为什么?
最佳答案
最相关的重载是:
void gather( const boost::mpi::communicator &comm, const T &in_value, T *out_values, int root )
void gather( const boost::mpi::communicator &comm, const T &in_value, int root )
void gather( const boost::mpi::communicator &comm, const T &in_value, std::vector<T> &out_values, int root )
所以要么通过指针传递:
boost::mpi::gather(boost_comm, distributed_boost_vector, &all_boost_vector, 0);
或者为 out_values
传递 std::vector:
std::vector<ublasv> out_values;
boost::mpi::gather(boost_comm, distributed_boost_vector, out_values, 0);
#include <boost/numeric/ublas/vector.hpp>
#include <boost/mpi/collectives/gather.hpp>
#include <iostream>
int main() {
boost::mpi::communicator boost_comm;
typedef boost::numeric::ublas::vector<double> ublasv;
ublasv distributed_boost_vector, all_boost_vector;
boost::mpi::gather(boost_comm, distributed_boost_vector, &all_boost_vector, 0);
std::vector<ublasv> out_values;
boost::mpi::gather(boost_comm, distributed_boost_vector, out_values, 0);
}
关于c++ - boost 收集 boost vector ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27688982/