How can I serialize arma::Col? Below are a MWE and the error output.
MWE:
#include
#i
According to @UKMonkey answer I wrote a working example. Actually for this case there is no need to split serialize tosave and load.
#include
#include
//#include
#include
#include "armadillo"
namespace mpi = boost::mpi;
typedef arma::Col::fixed<3> cvector;
//BOOST_SERIALIZATION_SPLIT_FREE(cvector)
namespace boost
{
namespace serialization
{
/*template
void save(Archive& ar, const cvector& cv, unsigned int)
{
std::cout << "saving" << std::endl;
ar& cv[0];
ar& cv[1];
ar& cv[2];
}
template
void load(Archive& ar, cvector& cv, unsigned int)
{
std::cout << "loading" << std::endl;
ar& cv[0];
ar& cv[1];
ar& cv[2];
}*/
template
inlide void serialize(Archive& ar, cvector& cv, unsigned int)
{
ar& cv[0];
ar& cv[1];
ar& cv[2];
}
}
}
struct S
{
int i;
cvector c;
friend class boost::serialization::access;
template
void serialize(Archive& ar, const unsigned int)
{
ar& i;
ar& c;
}
};
int main()
{
mpi::environment env;
mpi::communicator world;
S s;
if (world.rank() == 0)
{
s.i = 3;
s.c[0] = 2.;
s.c[1] = 4.;
world.send(1, 0, s);
}
else
{
world.recv(0, 0, s);
std::cout << s.i << std::endl;
std::cout << s.c[0] << std::endl;
std::cout << s.c[1] << std::endl;
}
return 0;
}