Re: [eigen] constants for things like JacobiRotation |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] constants for things like JacobiRotation
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 9 Aug 2011 01:40:39 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Ega938cS72e1iYp1A9tks8V739BQq8Jupd3WP85YaFI=; b=hMrae/8q+w3U8T1FG2J6wq0atJfpHgxUkji2XIn6rwX8OOFE3B5Ar+jfBQwPn2V/ct ehK0CYECWZ4HUMs54kKkuKvMnwY5gn8jmp+E3YOUguIhjJ9KnbviQuwNbtL4gnHvKDtx nxaNLWhc0x4+l4pF6DCKzJzjeko9esNVCMX/I=
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