Re: [eigen] Issues regarding Quaternion-alignment and const Maps |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Issues regarding Quaternion-alignment and const Maps
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 7 Jul 2010 10:26:11 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=ovX3EnfumvFDgXO5646qeSbsHxKRacIcYT1KOIH5ac4=; b=kZf60AdM2qBbvq1Bh8RE0aHp8CbmLA1QBH9iwpa6t2CwF1bP+Zst/LcectuyXMfYef jU/Zeiy/GPzzft6oaKu8NoFFxSqomLj5LWknqxMXIknLCv/GFuZiI1ZtrOT7BZxvCtCO TtBVEeKfQCYi/Qe0LfcvHk9pQGdKND8K/0AXc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=jGA4w4FzlWUfPRZtaSWjkT2xN6L+OawnU2JLQ1W9T24AWjJ4mG1ueptS8k4g2UE6ef u3hl8S8RTQGM/ty23N6+qC73cE1Qg20ptsTYGAENLzsfGQsJmNJ1CVNXEnuDKNsI0UzD D9C+HWyZanRSWTdvQWuiIDDUUDcocApDKX8TQ=
On Wed, Jul 7, 2010 at 9:56 AM, Christoph Hertzberg
<chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> first of all great work, everyone!
>
> I have two issues with Eigen2, which I'm not sure Eigen3 has solved/will
> solve (I did look at the new source, but might have overlooked something)..
>
> First, I guess there is no (easy) possibility to have an not-aligned
> quaternion (without disabling alignment globally).
> For ordanary matrices there is a Eigen::DontAlign option, which I haven't
> found for Quaternions. And currently I don't see a very lot of gain in
> vectorization of Quaternions, especially (quaternion * vector3) is not
> vectorized, and (quaternion * quaternion) only for float (at least in
> Eigen2).
With Eigen3 you can map unaligned data as a Quaternion, but that's
less convenient. So you would like a DontAlign option, e.g.:
Quaternion<double,DontAlign>
Then we should also add such an option to Translation and Transform.
Why not.
> The second issue is a bit more complicated:
> Eigen::Map severely violates const-correctness. I.e., it is possible to
> create a non-const Map from a (const double*).
> If you still accept API-changes, I would suggest having a Map and a ConstMap
> (similar to iterators in STL).
yes, that's not very nice. The only advantage of our current approach
is that keep the number of type instantiation to a minimum. The user
can still manually enforce constness by declaring the Map object
const:
const double* data= ...;
const Map<MatrixXf&> map(data,....);
But, sure, this is far to be satisfactory, for many reasons.
This issue also exists with named Block objects:
foo(const MatrixXf& m) {
Block<MatrixXf> bl(mat,0,0,,4,4);
bl.setZero();
}
API-wise, what about const qualifying the matrix type to enforce constness:
// here data can be a double* or a const double*
Map<const MatrixXf> mat(data,...);
// here data must be a double*
Map<MatrixXf> mat(data,...);
and we would do the same for Block. (Block and Map are based on the
same implementation).
Again the drawback is that we are artificially increasing the number
of types, and consequently compilation time and binary sizes....
> Ok, and actually a third very minor issue regarding Maps:
> Maps of fixed sizes should boil down to a single pointer, but they don't due
> to the ei_variable_if_dynamic-object, which is not allowed to have size 0,
> even if it contains no members.
> One possible solution (without to much code-rewriting) would be to combine
> the sizes and the m_data pointer to a single object, providing
> getter-functions for rows and cols, and some template-specializations if
> sizes are Dynamic (similar to how ei_matrix_storage is implemented)
Indeed, we had to introduce a separated ei_matrix_storage class for
that precise purpose. Actually, we did not thought that, e.g.,
sizeof(Map<Matrix4f>) would matter... but again, why not :)
gael
>
> Best regards,
> Christoph
>
> --
> ----------------------------------------------
> Dipl.-Inf. Christoph Hertzberg
> Cartesium 0.051
> Universität Bremen
> Enrique-Schmidt-Straße 5
> 28359 Bremen
>
> Tel: (+49) 421-218-64252
> ----------------------------------------------
>
>
>