Re: [eigen] AnyMatrixBase |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] AnyMatrixBase
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 9 Jun 2010 10:25:14 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=mFFXG6v7SXmvS3zao+08m99PsO6uItzCAp7N0iE0hA0=; b=ZqJ2L2xfkU9K8k2zvhfz/AIFUYVnVPcjO4KU+juEc1cHvS7KQH85z1v1j8kNC9Rj5H YIAQVFDzPfMVD48bade/j1ZpofLOYslhArzUDre8TO3i5vJeGPmOy6WnD/CoQyvuhYAg RTkkBoLIlch7DaIBXm3rPPMeZ9oX9R6H+6cwM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=GSLaruNj+tKIPhMvbY6y1zLM0+Ypgqq+bk4CKosr8p5+hOleE0RRNUTYzPzCtXKqj5 8oHR2ZENhE2T5q04cufndZTTR/lb3P1eyuVj+skj7eJqWB9bVWmFMiTM80gsnzXCQT0m +0THgBRx3oeOzbsA9FbAuuZ99snm7jgdeMWB4=
2010/6/9 Stefan Ulbrich <s.ulbrich@xxxxxxxxxxxxxx>:
> 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.
There is, it's template<typename Derived> MatrixBase.
Or if you have not only Matrix but also Array into play, replace
MatrixBase by DenseBase.
> 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.
This AnyMatrixBase is nowadays called EigenBase, but it is at the very
bottom of the class hierarchy, probably not what you want.
> How about an class exhibiting the most common methods of MatrixBase (Proxy Pattern)? This proxy could indeed be a virtual function allowing polymorphism.
No, virtual means runtime polymorphism, which is incompatible with
Eigen allowing optimizations to happen at compile time. The scheme
above, template<typename Derived> class Base, is a compile-time flavor
of polymorphism.
Benoit
>
>
> 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
>
>