[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Inheritence
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 5 Feb 2010 02:02:52 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=OIuAo2QeXVVQuFVcKByKccAsiaul0LW1AAlFNJzNlQE=; b=j0ANDQcs0w2Hg6XlQ/R0JrkdYdKj4G6ijOiGMZbwJC4czbNiyIX1QtXXJ75YS4hh5N SFJNNyubAj945ln0zT9Xr8UNQFslfPG0zCPQVnohOpYoBzQlWw46ZN3d4tVRQJIHY5Jo osPjvegHH3BZMHc4D/oZpgE762j+bTS7N13Q0=
- 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=sUFHlgEsyTt/eWyvLIf6zdtFIebOF8zPMxxvfKNX50iRecTrEMWJKBKimsaqv6ORj3 NsnESNRtX4ij6n8MByJCbMbkI+MpGNXlE5v1rtjRsARmDn5TfZZdawgK6AYRNLcTTnpr K4oxEBnQIXk4wTyEA1V00/TD+UVIIHdXRtF6A=
Oooh, I guess I see.
MyMatrix inherit Matrix which inherits MatrixBase<Matrix>.
So whenever an object of class MyMatrix is seen as a MatrixBase, it is
a MatrixBase<Matrix> so it uses ei_traits<Matrix>.
So, forget my recommendation about ei_traits.
2010/2/5 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> And, it's still mysterious to me how you guys can do without a
> specialization of ei_traits for your derived type...?
> As I saw it to define a class
> class MyMatrix : public Eigen::Matrix, you needed 2 things:
> 1) as Patrick said, reimplement ctors and assignment ops
> 2) define ei_traits<MyMatrix>, you can simply inherit ei_traits<Matrix>.
> 2010/2/5 Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>:
>> Mmmh, indeed!
>> I'm not (yet?) very familiar with all of this. I had the need to inherit and that worked for me so i've put it on the eigen documentation.
>> Would you mind if i copy your example to the official eigen doc ? Even better if you patch the file directly (doc/I00_CustomizingEigen.dox in the devel=main branch of eigen repository)
>> Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>
>> In data venerdì 05 febbraio 2010 04:05:50, Patrick Mihelich ha scritto:
>>> I think even that example is not perfect. Constructors are not inherited, so
>>> you will need to re-declare any constructors you want also. You probably
>>> want at least the copy constructor from an arbitrary Eigen matrix type. And
>>> operator= is more easily defined with a using statement if you do not need
>>> additional behavior from it. I wrote up an example at
>>> http://www.ros.org/wiki/eigen#Creating_typedefs_for_Eigen_types for a
>>> coworker who wanted something like a "templated typedef" over Eigen types.
>>> The inheritance approach as you can see is pretty complicated to get right.
>>> Usual caveats about inheriting from STL containers also apply, see for
>>> example this thread:
>>> On Thu, Feb 4, 2010 at 2:59 AM, Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>wrote:
>>> > It is not recommended, but possible, see
>>> > http://eigen.tuxfamily.org/dox-devel/CustomizingEigen.html#InheritingFromMatrix
>>> > ++
>>> > --
>>> > Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>
>>> > http://www.freehackers.org/thomas
>>> > In data giovedì 04 febbraio 2010 06:29:03, Daniel Stonier ha scritto:
>>> > > Just a curioisity...are there any ramifications to inheriting vector
>>> > > classes? Is it inadvisable for any particular reason?