[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] AnyMatrixBase
- From: Stefan Ulbrich <s.ulbrich@xxxxxxxxxxxxxx>
- Date: Wed, 9 Jun 2010 16:16:09 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:content-type :content-transfer-encoding:subject:date:message-id:to:mime-version :x-mailer; bh=7bkZnNuV+uXZpPc3yBV+6eRZBCLkzcdGur6df2eL82w=; b=HfIxi1+b2qfh5Ait84AgdJEeSXHLwM2R0nviXmWb2+Cpxuh9CelRfrevrVfq10ntFr jGxaXlJfiX+fA+L2Ir1SGpXBbBTM3p1ZWvUPq3NtgZY4JOiYboO5CmROznGhf1l4+oK0 Da0GFWVMuwEmers1WRwzqm46tdgnqXhGi1X8s=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=cim7eUPFelajJVxcnm1OT5cNRb161MyXt0TwBPMkzbW/yzrbETj+MD+xWNk0jM7/oW AR2fdm+oNSCXYrSyE+/2jlZRqOTlbJBbx6Of/ryqqXx1EPENaW0vbHSvcjCis4a3qda6 bE+8/52Kjqbiw12UCGjEYZDbLIvmn8rQLN/JI=
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