This is the minimal example, compiler output follows. Removing the
DontAlign flag solves the compilation issue. Thanks for looking into this.
#include <Eigen/Geometry>
void main()
{
typedef Eigen::Matrix<double, 2, 1, Eigen::DontAlign> Vec2d;
Vec2d v, w;
v = Eigen::Rotation2Dd(3.) * w;
}
cl Rotation2D_fail.cpp -I xs\src\eigen
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
Rotation2D_fail.cpp
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xlocale(337)
: warning C4530: C++ exception handler used, but unwind semantics are not
enabled. Specify /EHsc
Rotation2D_fail.cpp(7) : error C2666: 'Eigen::Rotation2D<double>::operator
*' : 2 overloads have similar conversions
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/Rotation2D.h(109):
could be 'Eigen::Matrix<double,2,1,0,2,1>
Eigen::Rotation2D<double>::operator *(const Eigen::Matrix<double,2,1,0,2,1>
&) const'
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/Rotation2D.h(101):
or 'Eigen::Rotation2D<double> Eigen::Rotation2D<double>::operator
*(const Eigen::Rotation2D<double> &) const'
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/RotationBase.h(56):
or 'Eigen::Transform<double,2,1,0>
Eigen::RotationBase<Eigen::Rotation2D<double>,2>::operator *(const
Eigen::Translation<double,2> &) const'
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/RotationBase.h(60):
or 'Eigen::Matrix<double,2,2,0,2,2>
Eigen::RotationBase<Eigen::Rotation2D<double>,2>::operator *(const
Eigen::UniformScaling<double> &) const'
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/RotationBase.h(80):
or 'Eigen::Transform<float,3,2,0>
Eigen::RotationBase<Derived,3>::operator *(const
Eigen::DiagonalMatrix<float,3,3> &,const Derived &)' [found using
argument-dependent lookup]
with
[
Derived=Eigen::Quaternion<float,0>
]
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/RotationBase.h(80):
or 'Eigen::Transform<double,3,2,0>
Eigen::RotationBase<Derived,3>::operator *(const
Eigen::DiagonalMatrix<double,3,3> &,const Derived &)' [found using
argument-dependent lookup]
with
[
Derived=Eigen::Quaternion<double,0>
]
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/RotationBase.h(80):
or 'Eigen::Transform<double,2,2,0>
Eigen::RotationBase<Eigen::Rotation2D<double>,2>::operator *(const
Eigen::DiagonalMatrix<double,2,2> &,const Derived &)' [found using
argument-dependent lookup]
with
[
Derived=Eigen::Rotation2D<double>
]
d:\src-perl\slic3r-eigenize\xs\src\eigen\eigen\src/Geometry/RotationBase.h(71):
or 'Eigen::Matrix<double,2,1,0,2,1>
Eigen::RotationBase<Eigen::Rotation2D<double>,2>::operator *<Derived>(const
Eigen::EigenBase<Derived> &) const'
with
[
Derived=Eigen::Matrix<double,2,1,2,2,1>
]
while trying to match the argument list
'(Eigen::Rotation2D<double>, Vec2d)'
On Mon, Aug 20, 2018 at 7:52 PM, Christoph Hertzberg <
Post by bubnikv[...]
Just for reference, I am using Visual Studio 2013 compiler, 64bit platform,
and Eigen 3.3.5.
[...]
Eigen::Matrix<double, 2, 1, Eigen::DontAlign> v, w;
Eigen::Rotation2Dd rot(3.);
v = rot * w;
v = rot * Eigen::Matrix<double, 2, 1>(w);
https://godbolt.org/z/EFv5ok
Maybe something else causes an error or it is a defect in MSVC2013. Could
you post the compile error you get (and a complete minimal source you tried
to compile + compilation flags)?
Maybe we find a workaround for that.
Christoph
Post by bubnikvSo thanks for the hint about I understand that there is always a way to
rotate the vector. I am just pointing out, that as a user of a finely
polished library, I would expect the Rotation2D to just work with both
aligned and non-aligned types.
Gruesse nach Bremen,
Vojtech
On Mon, Aug 20, 2018 at 3:37 PM, Christoph Hertzberg <
Post by bubnikvHello.
Post by bubnikvWe are developing a 3D printing software https://github.com/prusa3d/sli
c3r
(fork of http://slic3r.org/)
We are now trying to replace the homebrew point classes with the Eigen
fixed size types. As the code base is quite large, we want to avoid
alignment issues by declaring fixed vector types with the
Eigen::DontAlign
attribute. So far so good, with the exception of Eigen::Rotation2D, which
is not templated with the alignment attribute, so it cannot be used against
the fixed size matrices with Eigen::DontAlign. Is there any reason for
that? Would you guys please extend the class with the alignment template
attribute?
Rotation2D stores just a single Scalar (the angle), so there is no
need/possibility to align it.
Alternatively, you could store a 2D rotation as a 2x2 matrix, or as a
complex number (neither of them inherits from RotationBase, though).
We are thinking of using https://github.com/libigl/libigl for some
Post by bubnikvoperations on triangle meshes, where the vectorized operations may or may
not be beneficial. We may just disable alignment / vectorization for the
whole application. We are not sure about the performance penalty, but
looking at the evaluation of Eigen 2 from 2008
http://eigen.tuxfamily.org/index.php?title=Benchmark-August2008
the loss may be significant.
On modern CPUs the difference between aligned and not-aligned is far less
or even non-existing (except for effects like crossing cache-lines). And
with Eigen 3.3 it is possible to use vectorization on unaligned data
http://eigen.tuxfamily.org/bz/show_bug.cgi?id=256#c10
So make meaningful benchmarks on the CPU you want to target to decide if
you need to invest time into that.
We may then think about converting between the aligned / non aligned
Post by bubnikvvalues. Does Eigen support any conversion between aligned / unaligned
types? I know about the .cast<>() operator, but it does not allow me to
change the alignment attribute.
You can simply copy in either direction, or you can mix aligned and
non-aligned data inside expressions. No need to cast here.
Christoph
Thanks for your time,
Dr.-Ing. Christoph Hertzberg
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-StraÃe 5
28359 Bremen, Germany
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-StraÃe 1
28359 Bremen, Germany
Tel.: +49 421 178 45-4021
Zentrale: +49 421 178 45-0
Weitere Informationen: http://www.dfki.de/robotik
------------------------------------------------------------
-----------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter StraÃe 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.: DE 148646973
Steuernummer: 19/672/50006
------------------------------------------------------------
-----------
--
Dr.-Ing. Christoph Hertzberg
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-StraÃe 5
28359 Bremen, Germany
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-StraÃe 1
28359 Bremen, Germany
Tel.: +49 421 178 45-4021
Zentrale: +49 421 178 45-0
Weitere Informationen: http://www.dfki.de/robotik
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter StraÃe 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.: DE 148646973
Steuernummer: 19/672/50006
-----------------------------------------------------------------------