> Dear all,
>
> I have written a small 3 dimensional - double - vector library, and I was
> expecting that eigen performance was better than my library. Unfortunately,
> that is not the case. I have run a test and, for g++ 4.2 I got aprox 12
> secons with eigen and aprox 6 seconds with my library. With g++ 4.5, I got
> 5.5 aprox for eigen and 7 aprox for my library.
>
> I wluld like to know if I am using eigen the wrong way and that is the cause
> of this c++4.2 performance penalty (I do not have access to g++ 4.5 on the
> production servers) or this is just an special case.
>
> I am attaching the code and copying it here:
>
> #include "vector3d.hh"
> #include <eigen2/Eigen/Core>
> #include <eigen2/Eigen/Geometry>
> USING_PART_OF_NAMESPACE_EIGEN
> #include <iostream>
> using namespace std;
>
> typedef Vector3D vec_t; // my library
> //typedef Vector3d vec_t; // Eigen
>
> const double STEPS = 1.0e4;
>
> int main(void)
> {
> double i;
> vec_t v1, v2;
> vec_t v3 = v2;
> vec_t v5;
> ///*
> for(double j = 0; j < STEPS; j++) {
> v3 = v2;
> // copy constructor
> for(i = 0; i < STEPS; i++) {
> vec_t v4 = v3;
> }
> // copy
> for(i = 0; i < STEPS; i++) {
> v3 = vec_t(i/0.34, i, i*i);
> }
> // accessing one element
> for(i = 0; i < STEPS; i++) {
> v3[1] = i;
> }
> // long airhmetic operations
> v1 = vec_t(1,2.2,3.4);
> v2 = vec_t(-2, 3, 3);
> for(i = 0; i < STEPS; i++) {
> v3 = vec_t(i/0.34, i, i*i);
> v5 = v1+v2-v3;
> }
> // scalar product
> double result;
> for(i = 0; i < STEPS; i++) {
> result = v3.dot(v5);
> }
> // cross product
> for(i = 0; i < STEPS; i++) {
> v5 = v1.cross(v2);
> }
> // complex operation
> for(i = 0; i < 10*STEPS; i++) {
> v5 = v1 + 2.0*v2 - v3/4.0 + (v3.cross(v2));
> }
> // normalize
> for(i = 0; i < STEPS; i++) {
> v3 = v5.normalized();
> }
> for(i = 0; i < STEPS; i++) {
> v5.normalize();
> }
> }
> //*/
> clog << v1 << endl;
> clog << v2 << endl;
> clog << v3 << endl;
> clog << v5 << endl;
> return 0;
> }
>
>
>
> Best regards / Cordialmente,
>
> --
> William Oquendo
> Phd Candidate
> Simulation Of Physical Systems Group
> National University of Colombia
> Linux User # 321481
> *********************
> Este correo puede carecer de tildes o eñes ya que el teclado no contiene
> estos caracteres. Presento excusas por eso.
>
> *********************
>
>