How to Boost serialize a Eigen::Matrix class
Hi,
I have used Eigen::Matrix class in my project. Now i wants to serialize the value of it through Boost::Serialize. Can someone help me on how to achieve that.
My class is following,
class RandomNode {
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{ ar & is_leaf_; ar & depth_; ar & num_classes_; ar & num_features_; // Split node members ar & random_feature_indices_; ar & random_feature_weights_; ar & threshold_; ar & leftChild_; ar & rightChild_; }
bool is_leaf_;
int depth_;
int num_classes_;
int num_features_; // Split node members
VectorXi random_feature_indices_;
VectorXd random_feature_weights_;
double threshold_;
RandomNode* leftChild_;
RandomNode* rightChild_; // Methods and so on
}
And i am getting the following error :
/usr/include/boost/serialization/access.hpp:118:9: error: ‘class Eigen::Matrix
Hi, see the tutorials: http://www.boost.org/doc/libs/1_51_0/libs/serialization/doc/tutorial.html#no... On 2012-09-27 08:35, Dip Ghosh wrote:
Hi, I have used Eigen::Matrix class in my project. Now i wants to serialize the value of it through Boost::Serialize. Can someone help me on how to achieve that.
My class is following,
class RandomNode { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & is_leaf_; ar & depth_; ar & num_classes_; ar & num_features_; // Split node members ar & random_feature_indices_; ar & random_feature_weights_; ar & threshold_; ar & leftChild_; ar & rightChild_;
} bool is_leaf_; int depth_; int num_classes_; int num_features_;
// Split node members VectorXi random_feature_indices_; VectorXd random_feature_weights_; double threshold_; RandomNode* leftChild_; RandomNode* rightChild_; // Methods and so on }
And i am getting the following error :
/usr/include/boost/serialization/access.hpp:118:9: error: ‘class Eigen::Matrix
’ has no member named ‘serialize’ thanks in advance.
Regards, Dip
Hi, I'm just searching for a polygon Boolean library and I found this Boost.Polygon, but I met a problem with self intersect polygon. like below: typedef gtl::polygon_data<int> Polygon; std::vector<Polygon > ps; typedef Polygon::point_type Point; Point pts[] = { gtl::construct<Point>(0, 0), gtl::construct<Point>(10, 10), gtl::construct<Point>(10, 0), gtl::construct<Point>(0, 10) }; Polygon poly; gtl::set_points(poly, pts, pts+ sizeof(pts)/sizeof(Point)); ps += poly; I want to put a self intersect polygon |\ /| | \ / | | \/ | | /\ | | / \ | |/ \| into a Polygon set ps, But when I use ps += poly to put it, in the ps the polygon has been cut to /| / | / | \ | \ | \| and the left part doesn't exist anymore. I'm not sure whether I use it in a wrong way, or the library doesn't support this kind of operation? Best regards, Zeal --------------------------------------------------------------------------------------------------- Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) is intended only for the use of the intended recipient and may be confidential and/or privileged of Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying is strictly prohibited, and may be unlawful.If you have received this communication in error,please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you. ---------------------------------------------------------------------------------------------------
Hi Oswin,
Thanks for your reply. I have seen the tutorial already. I am new to boost so I apologize in advance if my question is very basic. So shall I have to put the serialize part inside my Eigen::Matrix class to work ? or can I put it inside my class ? Can you give me a small example please or explain a bit ?
Regards,
Dip
________________________________
From: Oswin Krause
Hi, I have used Eigen::Matrix class in my project. Now i wants to serialize the value of it through Boost::Serialize. Can someone help me on how to achieve that.
My class is following,
class RandomNode { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & is_leaf_; ar & depth_; ar & num_classes_; ar & num_features_; // Split node members ar & random_feature_indices_; ar & random_feature_weights_; ar & threshold_; ar & leftChild_; ar & rightChild_;
} bool is_leaf_; int depth_; int num_classes_; int num_features_;
// Split node members VectorXi random_feature_indices_; VectorXd random_feature_weights_; double threshold_; RandomNode* leftChild_; RandomNode* rightChild_; // Methods and so on }
And i am getting the following error :
/usr/include/boost/serialization/access.hpp:118:9: error: ‘class Eigen::Matrix
’ has no member named ‘serialize’ thanks in advance.
Regards, Dip
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi,
i directly linked to the example code in question where the
"non-intrusive" version was explained. You have to create a function
namespace boost::seialization with the following signature
namespace boost {
namespace serialization {
template
Hi Oswin, Thanks for your reply. I have seen the tutorial already. I am new to boost so I apologize in advance if my question is very basic. So shall I have to put the serialize part inside my Eigen::Matrix class to work ? or can I put it inside my class ? Can you give me a small example please or explain a bit ?
Regards, Dip
------------------------- FROM: Oswin Krause
TO: boost-users@lists.boost.org SENT: Thursday, September 27, 2012 1:26 PM SUBJECT: Re: [Boost-users] How to Boost serialize a Eigen::Matrix class Hi,
see the tutorials:
http://www.boost.org/doc/libs/1_51_0/libs/serialization/doc/tutorial.html#no...
On 2012-09-27 08:35, Dip Ghosh wrote:
Hi, I have used Eigen::Matrix class in my project. Now i wants to serialize the value of it through Boost::Serialize. Can someone help me on how to achieve that.
My class is following,
class RandomNode { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & is_leaf_; ar & depth_; ar & num_classes_; ar & num_features_; // Split node members ar & random_feature_indices_; ar & random_feature_weights_; ar & threshold_; ar & leftChild_; ar & rightChild_;
} bool is_leaf_; int depth_; int num_classes_; int num_features_;
// Split node members VectorXi random_feature_indices_; VectorXd random_feature_weights_; double threshold_; RandomNode* leftChild_; RandomNode* rightChild_; // Methods and so on }
And i am getting the following error :
/usr/include/boost/serialization/access.hpp:118:9: error: ‘class Eigen::Matrix
’ has no member named ‘serialize’ thanks in advance.
Regards, Dip
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org [1] http://lists.boost.org/mailman/listinfo.cgi/boost-users
Links: ------ [1] mailto:Boost-users@lists.boost.org
participants (3)
-
Dip Ghosh
-
Oswin Krause
-
李洋(zeal)