yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07836
serialize Eigen::MatrixXd
Hi,
May I know how do I serialize Eigen::MatrixXd in YADE such that I can
store in YADE_CLASS_BASE_DOC_ATTRS_CTOR
((Eigen::MatrixXd,Amatrix, ,, "a ")), without pre-defining the size of Amatrix?
I tried adding to Math.cpp:
template<class Archive>
void serialize(Archive & ar, Eigen::MatrixXd & g, const unsigned int version){
ar & BOOST_SERIALIZATION_NVP(g);
}
and Serializable.hpp:
namespace yade{
// by default, do not return reference; return value instead
template<typename T> struct py_wrap_ref: public boost::false_type{};
// specialize for types that should be returned as references
template<> struct py_wrap_ref<Vector3r>: public boost::true_type{};
template<> struct py_wrap_ref<Vector3i>: public boost::true_type{};
template<> struct py_wrap_ref<Vector2r>: public boost::true_type{};
template<> struct py_wrap_ref<Vector2i>: public boost::true_type{};
template<> struct py_wrap_ref<Quaternionr>: public boost::true_type{};
template<> struct py_wrap_ref<Matrix3r>: public boost::true_type{};
template<> struct py_wrap_ref<Eigen::MatrixXd>: public
boost::true_type{}; /**********new line *****/
//template<class C, typename T, T C::*A>
//void make_setter_postLoad(C& instance, const T& val){
instance.*A=val; cerr<<"make_setter_postLoad called"<<endl;
postLoad(instance); }
};
Anything else I missed?
Regards,
Boon