我需要通过MPI 传递由Armadillo C++ Matrix Library定义的矩阵或复杂矩阵类型.有什么好办法可以解决这个问题?我想过尝试:
写基质中以某种阵列,然后发送
行/的那个列,方法脱/再构建的阵列任一侧MPI_send/recv
使用类似的东西MPI_BYTE?
谢谢
所以我试图通过在一个节点上发送和接收一个简单的例子来实现其他方案.
translate.cpp
#include <mpi.h>
#include <armadillo>
#include <vector>
#include <cstdlib>
using namespace std;
using namespace arma;
using std::vector;
class ArmadilloMPI
{
public:
ArmadilloMPI(int nRows, int nCols)
{
this->nRows = nRows;
this->nCols = nCols;
realArray = (double **)malloc(nCols * nRows * sizeof(double*));
imArray = (double **)malloc(nCols * nRows * sizeof(double*));
}
~ArmadilloMPI()
{
free(realArray[0]);
free(realArray);
free(imArray[0]);
free(imArray);
}
double **realArray;
double **imArray;
int nCols; …Run Code Online (Sandbox Code Playgroud)