#include #include #include using namespace std; using namespace Eigen; #ifndef SCALAR #define SCALAR float #endif #ifndef SIZE #define SIZE 8 #endif typedef SCALAR Scalar; typedef NumTraits::Real RealScalar; typedef Matrix A; typedef Matrix B; typedef Matrix C; typedef Matrix M; template EIGEN_DONT_INLINE void transform(const Transformation& t, Data& data) { EIGEN_ASM_COMMENT("begin"); data = t * data; EIGEN_ASM_COMMENT("end"); } template EIGEN_DONT_INLINE void transform(const Quaternion& t, Data& data) { EIGEN_ASM_COMMENT("begin quat"); for(int i=0;i struct ToRotationMatrixWrapper { enum {Dim = T::Dim}; typedef typename T::Scalar Scalar; ToRotationMatrixWrapper(const T& o) : object(o) {} T object; }; template EIGEN_DONT_INLINE void transform(const ToRotationMatrixWrapper& t, Data& data) { EIGEN_ASM_COMMENT("begin quat via mat"); data = t.object.toRotationMatrix() * data; EIGEN_ASM_COMMENT("end quat via mat"); } template EIGEN_DONT_INLINE void transform(const Transform& t, Data& data) { data = (t * data.colwise().homogeneous()).template block(0,0); } template struct get_dim { enum { Dim = T::Dim }; }; template struct get_dim > { enum { Dim = R }; }; template struct bench_impl { static EIGEN_DONT_INLINE void run(const Transformation& t) { Matrix::Dim,N> data; data.setRandom(); bench_impl::run(t); BenchTimer timer; BENCH(timer,10,100000,transform(t,data)); cout.width(9); cout << timer.best() << " "; } }; template struct bench_impl { static EIGEN_DONT_INLINE void run(const Transformation&) {} }; template EIGEN_DONT_INLINE void bench(const std::string& msg, const Transformation& t) { cout << msg << " "; bench_impl::run(t); std::cout << "\n"; } int main(int argc, char ** argv) { Matrix mat34; mat34.setRandom(); Transform iso3(mat34); Transform aff3(mat34); Transform caff3(mat34); Transform proj3(mat34); Quaternion quat;quat.setIdentity(); ToRotationMatrixWrapper > quatmat(quat); Matrix mat33; mat33.setRandom(); cout.precision(4); std::cout << "N "; for(int i=0;i