#include #include #include #include #include namespace boost { namespace serialization { /// \brief save the object /// \param ar archive used /// \param g object to load template < class Archive, class S, int Rows_, int Cols_, int Ops_, int MaxRows_, int MaxCols_ > inline void save(Archive &ar, const Eigen::Array &g, const unsigned int) { int rows = g.rows(); int cols = g.cols(); ar &rows; ar &cols; ar &boost::serialization::make_array(g.data(), rows * cols); } /// \brief load the object /// \param ar archive used /// \param g object to load template < class Archive, class S, int Rows_, int Cols_, int Ops_, int MaxRows_, int MaxCols_ > inline void load( Archive &ar, Eigen::Array &g, const unsigned int) { int rows, cols; ar &rows; ar &cols; g.resize(rows, cols); ar &boost::serialization::make_array(g.data(), rows * cols); } /// \brief serialize the object Eigen /// \param ar archive used /// \param g object to load /// \param version useless template < class Archive, class S, int Rows_, int Cols_, int Ops_, int MaxRows_, int MaxCols_ > inline void serialize( Archive &ar, Eigen::Array< S, Rows_, Cols_, Ops_, MaxRows_, MaxCols_> &g, const unsigned int version) { split_free(ar, g, version); } } // namespace serialization } // namespace boost //---/ Wrapper for std::shared_ptr<> /------------------------------------------ namespace boost { namespace serialization { template void save(Archive &archive, const std::shared_ptr &value, const unsigned int /*version*/) { Type *data = value.get(); archive << data; } template void load(Archive &archive, std::shared_ptr &value, const unsigned int /*version*/) { Type *data; archive >> data; typedef std::weak_ptr WeakPtr; static boost::unordered_map hash; if (hash[data].expired()) { value = std::shared_ptr(data); hash[data] = value; } else value = hash[data].lock(); } template inline void serialize(Archive &archive, std::shared_ptr &value, const unsigned int version) { split_free(archive, value, version); } } } using namespace Eigen; int main(int argc, char *argv[]) { boost::mpi::environment env(argc, argv); boost::mpi::communicator world; std::shared_ptr t ; boost::mpi:: broadcast(world, t,0); return 0; }