[ 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 01:54:15 -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=jiI8xoU1IP3kA1nUoluwfiQziLntMnVi50dgdNehbuo=; b=iUI9noA4HwWmYNSn5pnB2p1jH/wKIvvw2IdmtNzBoHD32yLo3NXea1ekEoIRsFBMV/ 4lQ4UejXWVOZxRC5K4V+SzAJHp6tXIjyhdP7H894IZLKV1dnYvMBCCK4sl+QRQsgJksu MeNFjqKnWyHHZvn7P4av54ttLv5zze6GQeJfk=
- 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=Xy1ErmGCWFTOwATPonyoNikBp9pHNZm08VFN5NrsXS/SyhqXgwO4V6w7ll2cCD2AMI 7Cd+CNHEmSuH6TZ1L29GxOlhonaqrzBjofD7VliKoupbc/j2rvqg52v2RVTYE71c/ep1 uVlpOZ3lBdAoA3MtfPTuhbaoOuj+SqZyoykG4=
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?