quatmul.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <Eigen/Core>
00003 #include <Eigen/Geometry>
00004 #include <bench/BenchTimer.h>
00005 
00006 using namespace Eigen; 
00007 
00008 template<typename Quat>
00009 EIGEN_DONT_INLINE void quatmul_default(const Quat& a, const Quat& b, Quat& c)
00010 {
00011   c = a * b;
00012 }
00013 
00014 template<typename Quat>
00015 EIGEN_DONT_INLINE void quatmul_novec(const Quat& a, const Quat& b, Quat& c)
00016 {
00017   c = internal::quat_product<0, Quat, Quat, typename Quat::Scalar, Aligned>::run(a,b);
00018 }
00019 
00020 template<typename Quat> void bench(const std::string& label)
00021 {
00022   int tries = 10;
00023   int rep = 1000000;
00024   BenchTimer t;
00025   
00026   Quat a(4, 1, 2, 3);
00027   Quat b(2, 3, 4, 5);
00028   Quat c;
00029   
00030   std::cout.precision(3);
00031   
00032   BENCH(t, tries, rep, quatmul_default(a,b,c));
00033   std::cout << label << " default " << 1e3*t.best(CPU_TIMER) << "ms  \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
00034   
00035   BENCH(t, tries, rep, quatmul_novec(a,b,c));
00036   std::cout << label << " novec   " << 1e3*t.best(CPU_TIMER) << "ms  \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
00037 }
00038 
00039 int main()
00040 {
00041   bench<Quaternionf>("float ");
00042   bench<Quaterniond>("double");
00043 
00044   return 0;
00045 
00046 }
00047 


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:17