Re: [eigen] Inheritence

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


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>.

Benoit

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
> --
> Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>
> http://www.freehackers.org/thomas
>
> 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:
>> http://www.phwinfo.com/forum/comp-lang-cplus/333672-avoid-inheritance-std-map.html
>>
>> Patrick
>>
>> 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?
>> >
>> >
>> >
>>
>
>
>



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