Re: [eigen] ideas about the corner types

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


2010/2/5 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
>
>
> On Fri, Feb 5, 2010 at 11:43 AM, Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>
> wrote:
>>
>>
>> Something i dont understand: why do we need to use a trick to make a
>> compile-time parameter to look like a runtime one ?
>> Why not (as is done in other parts of eigen) do corner<TopLeft>(3,3) and
>> makes this explicit ?
>
> sure, ideally I would prefer your suggestion but c++ is such that the trick
> has the advantage of not needing the template prefix (in template code):
>
> m.corner(TopLeft,3,3)
>
> vs
>
> m.template corner<TopLeft>(3,3)

Still, Thomas has a point since elsewhere in Eigen we're just using
template parameters. Perhaps we should be consistent. I guess that the
biggest argument in favor of my corner() proposal here is to keep the
same API as Eigen2... as you say, one could keep the current function
unchanged in              Eigen2support and move to an "officially"
templated one...

Notice that _every_ templated method could be replaced by an
_implicitly templated one in this way_, general int parameters could
be wrapped in a CompileTime<int> empty struct, etc... so we just have
to make a choice, to use such tricks or to use plain template methods,
and be consistent with that... thanks for the reminder.

Benoit

>
> gael.
>
>>
>> (The trick could still be used in the eigen2 compatibility stuff to keep
>> the old api)
>>
>> Thomas
>> --
>> Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>
>> http://www.freehackers.org/thomas
>>
>> In data venerdì 05 febbraio 2010 10:45:21, Benoit Jacob ha scritto:
>> > >> Currently matrix.corner(TopLeft,3,3) takes TopLeft as a runtime
>> > >> parameter. This is based around the assumption that the compiler
>> > >> resolves this at compile time. In practice that seems to work
>> > >> although
>> > >> I only checked GCC. Here's an idea to resolve this at runtime: let
>> > >> TopLeft be an object of type CornerType<TopLeft_t>, etc.. taking a
>> > >> common template CornerType type allows to write the function only
>> > >> once, yet have a guarantee that that stuff resolves at compile time..
>> > >
>> > > Sounds good, and that does not change the API right ?
>> >
>> > No API change, assuming that nobody was perverse enough to actually
>> > pass a runtime variable, whose value actually isn't known at compile
>> > time, as the corner type.
>>
>>
>



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