c++ - boost 收集 boost vector

标签 c++ boost vector mpi

我有一个分布式 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);

Live On Coliru

#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/

相关文章:

c++ - 使用 boost 和标准 C++ 进行 Unicode 安全查找

c++ - 如何使用 Ninja 在 C++ 中编译 "Hello World"?

c++ - 多个类,相同的公共(public)接口(interface)

c++ - Windows/c++-使用 boost 的日期减法(周/月/年)

c++ - boost 正则表达式中的链接器错误

c++ - 为什么 std::vector 不保留 "double"它的容量,而调整大小呢?

c++ - 对于网络映射驱动器形式的 C++ 代码,rsync 失败

c++ - 将非成员转换重载到 bool 运算符

c++ - 如何删除不断改变其大小的 vector 的一系列元素(C++)?

c++ - 在 C++ 中复制一维二维 vector 的最快方法