Re: [eigen] constants for things like JacobiRotation

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


2011/8/3 Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>:
>
>
> Hello,
>
>
>
> "It would be great to have" (tm) constants for things like JacobiRotation.
>
>
>
> Can the compiler optimize such a thing without calling the JacobiRotation
> ctor each time the code goes through ?
>
> JacobiRotation<Scalar> v;
>
> ...
>
> v = JacobiRotation<Scalar>(1,0);
>
>
>
> Is it possible to add some constants, probably within the JacobiRotation
> class itself so that we can do things like
>
> v = JacobiRotation<Scalar>::Identity;
>
> or
>
> v = JacobiRotation<Scalar>::RotationSymmetry;

Really, the Eigen approach to this has always been to have a static
method returning a new (lightweight) object. See for example the
MatrixBase::Identity() methods. Just like the compiler is able to
optimize away expression objects, it should be able to optimize away
constant JacobiRotations. So it should be OK to just return a
JacobiRotation by value. At least, I would not worry about that until
concrete perf issues are hit in practice.

So, feel free to add such static methods, as long as their return type
is a lightweight type (as light or lighter than usual expression
types).

Cheers,
Benoit



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