[eigen] AnyMatrixBase

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hello,

I've been looking for a common base class for MatrixXi and CwiseNullaryOp in oder to address both by a pointer. As I understood there doesn't exist any in order to avoid virtual classes.
In the forum I found a thread refering to a class AnyMatrixBase which I'm unable to find in the recent development tree. A different suggestion was using variant classes. 
How about an class exhibiting the most common methods of MatrixBase (Proxy Pattern)? This proxy could indeed be a virtual function allowing polymorphism.


template <typename Scalar>
class
AnyMatrixBase {
        public:
        virtual Scalar operator()(int,int) const = 0;
};


template<typename MatrixType>
class AnyMatrix : public AnyMatrixBase<typename ei_traits<MatrixType>::Scalar>  {
        public:
                typedef typename ei_traits<MatrixType>::Scalar Scalar; 
                AnyMatrix(MatrixType *m) : m_ref(m){};
                virtual Scalar operator()(int i,int j) const {
                        m_ref->operator()(i,j);
                };
        private:
                boost::scoped_ptr<MatrixType> m_ref;
};


A completely different question: are there any attempts to serialize Eigen objects (e.g., like boost.serialize does)?


Best regards 
Stefan


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/