Ported to Eigen 2

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
http://eigen.tuxfamily.org/api

I’d like to show you one of the places that benefited dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

  Vector3d axisNormalized = axis.normalized();
  Vector3d ortho1, ortho2;
  ortho1.loadOrtho(axisNormalized);
  ortho1 *= radius;
  axisNormalized.cross( ortho1, &ortho2 );

  // construct the 4D transformation matrix
  Matrix4d matrix;

  matrix(0, 0) = ortho1(0);
  matrix(1, 0) = ortho1(1);
  matrix(2, 0) = ortho1(2);
  matrix(3, 0) = 0.0;

  matrix(0, 1) = ortho2(0);
  matrix(1, 1) = ortho2(1);
  matrix(2, 1) = ortho2(2);
  matrix(3, 1) = 0.0;

  matrix(0, 2) = axis(0);
  matrix(1, 2) = axis(1);
  matrix(2, 2) = axis(2);
  matrix(3, 2) = 0.0;

  matrix(0, 3) = end1(0);
  matrix(1, 3) = end1(1);
  matrix(2, 3) = end1(2);
  matrix(3, 3) = 1.0;

  //now we can do the actual drawing !
  glPushMatrix();
  glMultMatrixd( matrix.array() );
  glCallList( d->displayList );
  glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how expression
templates allow to perform all vector operations in place, directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

  Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
  matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() * radius;
  matrix.block<3,1>(0,1) = axisNormalized.cross(matrix.block<3,1>(0,0));
  matrix.block<3,1>(0,3) = end1;

  //now we can do the actual drawing !
  glPushMatrix();
  glMultMatrixd( matrix.data() );
  glCallList( d->displayList );
  glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster! Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by it.
I saw a lot of that in our source code. Applying a translation is just
adding two vectors. If you have a vector Position and want to apply to
it a translation by vector Displacement, the result is just Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object libavogadro/src/CMakeFiles/avogadro-
lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In member
function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>, 1,
3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In member
function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In member
function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In member
function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited dramatically
from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

 Vector3d axisNormalized = axis.normalized();
 Vector3d ortho1, ortho2;
 ortho1.loadOrtho(axisNormalized);
 ortho1 *= radius;
 axisNormalized.cross( ortho1, &ortho2 );

 // construct the 4D transformation matrix
 Matrix4d matrix;

 matrix(0, 0) = ortho1(0);
 matrix(1, 0) = ortho1(1);
 matrix(2, 0) = ortho1(2);
 matrix(3, 0) = 0.0;

 matrix(0, 1) = ortho2(0);
 matrix(1, 1) = ortho2(1);
 matrix(2, 1) = ortho2(2);
 matrix(3, 1) = 0.0;

 matrix(0, 2) = axis(0);
 matrix(1, 2) = axis(1);
 matrix(2, 2) = axis(2);
 matrix(3, 2) = 0.0;

 matrix(0, 3) = end1(0);
 matrix(1, 3) = end1(1);
 matrix(2, 3) = end1(2);
 matrix(3, 3) = 1.0;

 //now we can do the actual drawing !
 glPushMatrix();
 glMultMatrixd( matrix.array() );
 glCallList( d->displayList );
 glPopMatrix();

}

Here is the new Cylinder::draw() using Eigen 2. Notice how expression
templates allow to perform all vector operations in place, directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

 Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
 matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() *  

radius;
matrix.block<3,1>(0,1) =
axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

 //now we can do the actual drawing !
 glPushMatrix();
 glMultMatrixd( matrix.data() );
 glCallList( d->displayList );
 glPopMatrix();

}

OK, finally, I’d like to take this occasion to draw your attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster! Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by it.
I saw a lot of that in our source code. Applying a translation is just
adding two vectors. If you have a vector Position and want to apply to
it a translation by vector Displacement, the result is just Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Could you update me on how to handle the translation files? There was
some issue with taking the .po files from Launchpad and then using
them in Avogadro. I admit I have forgotten. (Or was the problem in
generating a good POT?)

But I do think the Launchpad effort has been a great success. Thanks!

Thanks very much,
-Geoff

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();

}

Here is the new Cylinder::draw() using Eigen 2. Notice how expression
templates allow to perform all vector operations in place, directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() * radius;
matrix.block<3,1>(0,1) = axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();

}

OK, finally, I’d like to take this occasion to draw your attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster! Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by it.
I saw a lot of that in our source code. Applying a translation is just
adding two vectors. If you have a vector Position and want to apply to
it a translation by vector Displacement, the result is just Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.

Hi Benoît.

Finally, obtained Eigen2 from svn.
On a Fedora8 box, avogadro builds O.K.
Did the same on my Mac, rather then getting
it from the Wiki, but I still get the same errors.

Any idea ?

Louis

Le 25 août 08 à 21:08, jacob@math.jussieu.fr a écrit :

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place
as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to
find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited dramatically
from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how
expression
templates allow to perform all vector operations in place,
directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() *
radius;
matrix.block<3,1>(0,1) =
axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your attention
on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster!
Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by
it.
I saw a lot of that in our source code. Applying a translation is
just
adding two vectors. If you have a vector Position and want to
apply to
it a translation by vector Displacement, the result is just
Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

Finally, obtained Eigen2 from svn.
On a Fedora8 box, avogadro builds O.K.
Did the same on my Mac, rather then getting
it from the Wiki, but I still get the same errors.

Any idea ?

Probably, on your Mac, it is still using the old Eigen2, which must
still be installed somewhere. Find it, remove it, erase your
builddir’s content and retry :slight_smile:

These errors are 100% guaranteed to be caused by an old Eigen2, and
not to be Mac-specific.

Cheers,
Benoit

Louis

Le 25 août 08 à 21:08, jacob@math.jussieu.fr a écrit :

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how expression
templates allow to perform all vector operations in place, directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() * radius;
matrix.block<3,1>(0,1) = axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster! Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by it.
I saw a lot of that in our source code. Applying a translation is just
adding two vectors. If you have a vector Position and want to apply to
it a translation by vector Displacement, the result is just Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.

Hi Geoff.

Initially, there was a problem with the pot file. This is resolved
since the
end of June.

The pot file can readily be updated as follows :

make update-translations
ts2po -P avogadro_en_GB.ts avogadro_somerevision.pot.

I usually edit the en_GB file to remove all " type=unfinished" in the
translation
sections prior to running ts2po. Probably useless.

The pot file has the “correct” format, for example:

"#: AddEngineDialog#1
msgid “Add Display Type”
msgstr “”

#: AddEngineDialog#2
msgid “Type:”
msgstr “” "

The other way around, I use msgmerge to produce a new avogadro-LANG.po
and po2ts for creation of the new avogadro_LANG.ts.

msgmerge lang.po new.pot -o newlang.po
po2ts newlang.po newlang.ts

and lrelease from the command line eventually.

For reasons I do not understand, some of the old translations are
labelled fuzzy
in the new po file; may due to inconsistencies in the translations ?
They have to
be reset manually. The french version has 122 such strings.

Another point : I have been unable so far to use pomerge2 to automate
the
generation of new po files.

Final word, I use the translation toolkit version 1.1.1 .
http://translate.sourceforge.net/wiki/toolkit/index

Hope this helps.

Cheers,

Louis

Le 25 août 08 à 21:06, Geoffrey Hutchison a écrit :

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Could you update me on how to handle the translation files? There was
some issue with taking the .po files from Launchpad and then using
them in Avogadro. I admit I have forgotten. (Or was the problem in
generating a good POT?)

But I do think the Launchpad effort has been a great success. Thanks!

Thanks very much,
-Geoff


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

Hi again.

Now I get different errors on a G5 Powerpc Mac :

[ 0%] Building CXX object libavogadro/src/CMakeFiles/avogadro-lib.dir/
camera.o
/usr/include/c++/4.0.0/bits/stl_vector.h:148: error: template class
without a name
/usr/include/c++/4.0.0/bits/stl_vector.h:154: error: expected
unqualified-id before ‘<’ token
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: ‘vector_type’ was
not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: ‘vector_type’ was
not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected
unqualified-id before ‘const’
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected )' before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:199: error: expected )’
before ‘__n’
/usr/include/c++/4.0.0/bits/stl_vector.h:216: error: expected )' before ‘__n’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected unqualified-id before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected )’
before ‘const’

Compiles fine on a Intel Macbook. Same system same compiler.

No longer understand anything.

Louis

Le 26 août 08 à 16:38, jacob@math.jussieu.fr a écrit :

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

Finally, obtained Eigen2 from svn.
On a Fedora8 box, avogadro builds O.K.
Did the same on my Mac, rather then getting
it from the Wiki, but I still get the same errors.

Any idea ?

Probably, on your Mac, it is still using the old Eigen2, which must
still be installed somewhere. Find it, remove it, erase your
builddir’s content and retry :slight_smile:

These errors are 100% guaranteed to be caused by an old Eigen2, and
not to be Mac-specific.

Cheers,
Benoit

Louis

Le 25 août 08 à 21:08, jacob@math.jussieu.fr a écrit :

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations
are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same
place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to
find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see
the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited
dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how
expression
templates allow to perform all vector operations in place,
directly on
the blocks of the matrix, removing the need to first construct
these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() *
radius;
matrix.block<3,1>(0,1) =
axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your
attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but
the
components were not stored as an array, hence there was no
guarantee
that they would be adjacent in memory. My fault really, I wrote
that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster!
Since
our data is generally stored as vectors, they’re also easier to
call
and less error-prone.

By the way, i also made GLPainter use more Color::apply()
instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need
to
construct a 4x4 transformation matrix and multiply your vector
by it.
I saw a lot of that in our source code. Applying a translation
is just
adding two vectors. If you have a vector Position and want to
apply to
it a translation by vector Displacement, the result is just
Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

Hi,

Here is my best guess about what’s happening now: Eigen defines
symbols that conflict with std symbols in a .cpp file which does
“using” on these two namespaces; moreover since this occurs only on
your G5 and not on the Intel, this means that the problem is with
symbols defined in Eigen’s AltiVec vectorization code.

Doing “using namespace Eigen” is more problematic with Eigen2 than
with Eigen1 because it now defines more symbols.

The solution is to go to camera.cpp (and any other .cpp file
triggering this problem) and to replace

using namespace Eigen;

by

USING_PART_OF_NAMESPACE_EIGEN

without final ;

This macro is provided by Eigen2 as a safer, more conservative to
“using namespace Eigen;”, it just does “using” on the most commonly
used symbols.

If after that the compiler complains that some symbol is undefined,
just prepend it by “Eigen::”. For example, Transform3d becomes
Eigen::Transform3d.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi again.

Now I get different errors on a G5 Powerpc Mac :

[ 0%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/usr/include/c++/4.0.0/bits/stl_vector.h:148: error: template class
without a name
/usr/include/c++/4.0.0/bits/stl_vector.h:154: error: expected
unqualified-id before ‘<’ token
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected
unqualified-id before ‘const’
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected )' before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:199: error: expected )’
before ‘__n’
/usr/include/c++/4.0.0/bits/stl_vector.h:216: error: expected )' before ‘__n’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected unqualified-id before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected )’
before ‘const’

Compiles fine on a Intel Macbook. Same system same compiler.

No longer understand anything.

Louis

Le 26 août 08 à 16:38, jacob@math.jussieu.fr a écrit :

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

Finally, obtained Eigen2 from svn.
On a Fedora8 box, avogadro builds O.K.
Did the same on my Mac, rather then getting
it from the Wiki, but I still get the same errors.

Any idea ?

Probably, on your Mac, it is still using the old Eigen2, which must
still be installed somewhere. Find it, remove it, erase your
builddir’s content and retry :slight_smile:

These errors are 100% guaranteed to be caused by an old Eigen2, and
not to be Mac-specific.

Cheers,
Benoit

Louis

Le 25 août 08 à 21:08, jacob@math.jussieu.fr a écrit :

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how expression
templates allow to perform all vector operations in place, directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() * radius;
matrix.block<3,1>(0,1) = axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster! Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by it.
I saw a lot of that in our source code. Applying a translation is just
adding two vectors. If you have a vector Position and want to apply to
it a translation by vector Displacement, the result is just Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.

Hi

Defenitely not working on a G5: same errors.

Louis

Le 26 août 08 à 18:23, jacob@math.jussieu.fr a écrit :

Hi,

Here is my best guess about what’s happening now: Eigen defines
symbols that conflict with std symbols in a .cpp file which does
“using” on these two namespaces; moreover since this occurs only on
your G5 and not on the Intel, this means that the problem is with
symbols defined in Eigen’s AltiVec vectorization code.

Doing “using namespace Eigen” is more problematic with Eigen2 than
with Eigen1 because it now defines more symbols.

The solution is to go to camera.cpp (and any other .cpp file
triggering this problem) and to replace

using namespace Eigen;

by

USING_PART_OF_NAMESPACE_EIGEN

without final ;

This macro is provided by Eigen2 as a safer, more conservative to
“using namespace Eigen;”, it just does “using” on the most commonly
used symbols.

If after that the compiler complains that some symbol is undefined,
just prepend it by “Eigen::”. For example, Transform3d becomes
Eigen::Transform3d.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi again.

Now I get different errors on a G5 Powerpc Mac :

[ 0%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/usr/include/c++/4.0.0/bits/stl_vector.h:148: error: template class
without a name
/usr/include/c++/4.0.0/bits/stl_vector.h:154: error: expected
unqualified-id before ‘<’ token
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: template
argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: template
argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected
unqualified-id before ‘const’
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected )' before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:199: error: expected )’
before ‘__n’
/usr/include/c++/4.0.0/bits/stl_vector.h:216: error: expected )' before ‘__n’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected unqualified-id before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected )’
before ‘const’

Compiles fine on a Intel Macbook. Same system same compiler.

No longer understand anything.

Louis

Le 26 août 08 à 16:38, jacob@math.jussieu.fr a écrit :

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

Finally, obtained Eigen2 from svn.
On a Fedora8 box, avogadro builds O.K.
Did the same on my Mac, rather then getting
it from the Wiki, but I still get the same errors.

Any idea ?

Probably, on your Mac, it is still using the old Eigen2, which must
still be installed somewhere. Find it, remove it, erase your
builddir’s content and retry :slight_smile:

These errors are 100% guaranteed to be caused by an old Eigen2, and
not to be Mac-specific.

Cheers,
Benoit

Louis

Le 25 août 08 à 21:08, jacob@math.jussieu.fr a écrit :

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3,
48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective()
const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d
Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad
translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same
place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails
to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If
you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll
see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited
dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take
full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how
expression
templates allow to perform all vector operations in place,
directly on
the blocks of the matrix, removing the need to first construct
these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() *
radius;
matrix.block<3,1>(0,1) =
axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your
attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method
but the
components were not stored as an array, hence there was no
guarantee
that they would be adjacent in memory. My fault really, I
wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are
faster! Since
our data is generally stored as vectors, they’re also easier
to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply()
instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t
need to
construct a 4x4 transformation matrix and multiply your vector
by it.
I saw a lot of that in our source code. Applying a translation
is just
adding two vectors. If you have a vector Position and want to
apply to
it a translation by vector Displacement, the result is just
Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere
in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

Hi,

OK let me explain better the problem. ‘vector’ is a special keyword
used in AltiVec vectorization. But ‘vector’ is a also a class template
in namespace std. Somehow, in the setup of Avogadro, the two conflict
together.

Here’s a quick workaround for now: define the EIGEN_DONT_VECTORIZE
keyword. You can do that by editing our top-level CMakeLists and adding:
add_definitions(“-DEIGEN_DONT_VECTORIZE”)
This should be enclosed in an if…endif checking if the platform has
AltiVec support. I don’t know what the correct cmake symbol to check
is, probably google can tell you.

Let me know if you have any trouble putting that in practice.

I’ll talk to Konstantinos about your issue so he can hopefully fix it.

As a result, you won’t benefit from vectorization, but for now it
doesn’t make a big difference as Avogadro does mostly 3d operations
that are not really vectorizable. Vectorization works with packets of
128 bits i.e, 2 double’s so operations with Vector2d, Vector4d and
Vector4f are well optimized, but not Vector3d.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi

Defenitely not working on a G5: same errors.

Louis

Le 26 août 08 à 18:23, jacob@math.jussieu.fr a écrit :

Hi,

Here is my best guess about what’s happening now: Eigen defines
symbols that conflict with std symbols in a .cpp file which does
“using” on these two namespaces; moreover since this occurs only on
your G5 and not on the Intel, this means that the problem is with
symbols defined in Eigen’s AltiVec vectorization code.

Doing “using namespace Eigen” is more problematic with Eigen2 than
with Eigen1 because it now defines more symbols.

The solution is to go to camera.cpp (and any other .cpp file
triggering this problem) and to replace

using namespace Eigen;

by

USING_PART_OF_NAMESPACE_EIGEN

without final ;

This macro is provided by Eigen2 as a safer, more conservative to
“using namespace Eigen;”, it just does “using” on the most commonly
used symbols.

If after that the compiler complains that some symbol is undefined,
just prepend it by “Eigen::”. For example, Transform3d becomes
Eigen::Transform3d.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi again.

Now I get different errors on a G5 Powerpc Mac :

[ 0%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/usr/include/c++/4.0.0/bits/stl_vector.h:148: error: template class
without a name
/usr/include/c++/4.0.0/bits/stl_vector.h:154: error: expected
unqualified-id before ‘<’ token
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected
unqualified-id before ‘const’
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected )' before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:199: error: expected )’
before ‘__n’
/usr/include/c++/4.0.0/bits/stl_vector.h:216: error: expected )' before ‘__n’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected unqualified-id before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected )’
before ‘const’

Compiles fine on a Intel Macbook. Same system same compiler.

No longer understand anything.

Louis

Le 26 août 08 à 16:38, jacob@math.jussieu.fr a écrit :

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

Finally, obtained Eigen2 from svn.
On a Fedora8 box, avogadro builds O.K.
Did the same on my Mac, rather then getting
it from the Wiki, but I still get the same errors.

Any idea ?

Probably, on your Mac, it is still using the old Eigen2, which must
still be installed somewhere. Find it, remove it, erase your
builddir’s content and retry :slight_smile:

These errors are 100% guaranteed to be caused by an old Eigen2, and
not to be Mac-specific.

Cheers,
Benoit

Louis

Le 25 août 08 à 21:08, jacob@math.jussieu.fr a écrit :

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited
dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how expression
templates allow to perform all vector operations in place, directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() * radius;
matrix.block<3,1>(0,1) = axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster! Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by it.
I saw a lot of that in our source code. Applying a translation is just
adding two vectors. If you have a vector Position and want to apply to
it a translation by vector Displacement, the result is just Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.

Quoting Geoffrey Hutchison geoff.hutchison@gmail.com:

On Aug 26, 2008, at 3:51 PM, jacob@math.jussieu.fr wrote:

OK let me explain better the problem. ‘vector’ is a special keyword
used in AltiVec vectorization. But ‘vector’ is a also a class template
in namespace std. Somehow, in the setup of Avogadro, the two conflict
together.

Well, then in the Avogadro code, we should take out “using” for “std”
and add explicit namespace for std::vector.

Hm I have written to Konstantinos to ask him if there isn’t an
alternative to the “vector” keyword for vectorization. For SSE, there
is, so I hope that for AltiVec too.

Then I’m not 100% what exactly is causing trouble in Avogadro. I don’t
see where the “using namespace std;” is and I would rather first see
if we can change Eigen so it doesn’t trigger such problems.

128 bits i.e, 2 double’s so operations with Vector2d, Vector4d and
Vector4f are well optimized, but not Vector3d.

Are you saying that we should use Vector4d or Vector4f internally and
ignore the extra data?

Basically, I consider this to be Eigen’s work, not Avogadro’s. So when
I have time I might work at adding the feature to Eigen, to make 3D
vectors 128-bit aligned, and so enable vectorization for them ignoring
the gaps. By itself this is rather trivial, but a few packet
instructions are going to be broken in this scheme so we must make
sure to avoid them.

Avogadro should not have to implement that. If/when I implement that,
I’ll tell you how to enable it (a compile-time switch). It shouldn’t
require any change in Avogadro’s code. The whole point of Eigen is to
abstract that.

This won’t be a “revolution” for avogadro:

  • it would increase memory usage of geometric objects by +33%
  • since avogadro uses double precision, it would only reduce the
    number of flops from 3 to 2, so the max possible speed improvement is
    +50%
  • if avogadro switches to single precision then it can hope for x3
    speed improvement, but then since openbabel is definitely keeping
    double precision there would be the cost of float/double conversions
    which could outweigh that.
  • avogadro is probably spending a large part of its time waiting for
    OpenGL rendering. I don’t know how much time is spent in Eigen.
  • for the heavier numerical operations such as force fields, as
    discussed with Tim, the vectorization works very well already. For
    example, the other day, Tim had an array of n Vector3d’s. He stored it
    as a Eigen::Matrix<double,3,Eigen::Dynamic> and Eigen was
    automatically understanding that for the operations that he was doing,
    the matrix could be understood as a single vector of length 3*n
    instead of n vectors of size 3. The result was very good vectorization
    (x2 speed improvement, the maximum with double’s).

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.

Hi,

This is now fixed in Eigen revision 852991.

The fix was to replace ‘vector’ by ‘__vector’. Please let me know if
there is still a problem.

And, great news about the 13 translations !

Thanks,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi again.

Now I get different errors on a G5 Powerpc Mac :

[ 0%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/usr/include/c++/4.0.0/bits/stl_vector.h:148: error: template class
without a name
/usr/include/c++/4.0.0/bits/stl_vector.h:154: error: expected
unqualified-id before ‘<’ token
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:162: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: ‘vector_type’
was not declared in this scope
/usr/include/c++/4.0.0/bits/stl_vector.h:163: error: template argument
2 is invalid
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected
unqualified-id before ‘const’
/usr/include/c++/4.0.0/bits/stl_vector.h:188: error: expected )' before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:199: error: expected )’
before ‘__n’
/usr/include/c++/4.0.0/bits/stl_vector.h:216: error: expected )' before ‘__n’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected unqualified-id before ‘const’ /usr/include/c++/4.0.0/bits/stl_vector.h:233: error: expected )’
before ‘const’

Compiles fine on a Intel Macbook. Same system same compiler.

No longer understand anything.

Louis

Le 26 août 08 à 16:38, jacob@math.jussieu.fr a écrit :

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

Finally, obtained Eigen2 from svn.
On a Fedora8 box, avogadro builds O.K.
Did the same on my Mac, rather then getting
it from the Wiki, but I still get the same errors.

Any idea ?

Probably, on your Mac, it is still using the old Eigen2, which must
still be installed somewhere. Find it, remove it, erase your
builddir’s content and retry :slight_smile:

These errors are 100% guaranteed to be caused by an old Eigen2, and
not to be Mac-specific.

Cheers,
Benoit

Louis

Le 25 août 08 à 21:08, jacob@math.jussieu.fr a écrit :

Hi Louis,

These errors means that you have an old version of Eigen 2: the
compiler complains about methods that we introducted recently.

Most likely, you used alpha7 or you fetched Eigen2 from its old
location at /branches/work/eigen2.

The latest svn revision, which you need, is located at
/trunk/kdesupport/eigen2.

I updated the wiki to reflect this.

Cheers,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi Benoît.

I have just updated to Eigen2 and the latest revision on my Mac
(Leopard 10.5.4).
Here is what I get when building (short version) :

“[ 8%] Building CXX object
libavogadro/src/CMakeFiles/avogadro-lib.dir/camera.o
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::initializeViewPoint()’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:164:
error: ‘class Eigen::Block<Eigen::Matrix<double, 3, 3, 3, 3, 48u>,
1, 3, 1, 32>’ has no member named ‘unitOrthogonal’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:168:
error: ‘class Eigen::Transform3d’ has no member named ‘linear’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyPerspective() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:196:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘void Avogadro::camera::applyModelview() const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:201:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp: In
member function ‘Eigen::Vector3d Avogadro::camera::unProject(const
Eigen::Vector3d&) const’:
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’
/Users/ricard/svn/avogadro/trunk/libavogadro/src/camera.cpp:209:
error: ‘class Eigen::Transform3d’ has no member named ‘data’”

Mac specific ?

Aside from that, I am glad to see that the Launchpad translations are
paying off: we are now at 13 translations.

Louis

Le 25 août 08 à 06:39, jacob@math.jussieu.fr a écrit :

Hi List,

Avogadro is ported to Eigen 2, as of r1568.

You’ll need to check out Eigen2 from kdesupport, at the same place as
usual except that ‘eigen’ becomes ‘eigen2’ :

svn co svn:://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2

To install Eigen2, do:

mkdir eigen2-build
cd eigen2-build
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix …/eigen2
make install

Now you should be able to build Avogadro. If cmake ever fails to find
Eigen2, use -DEIGEN2_INCLUDE_DIR=/path/to/eigen2 (the directory
containing the Eigen subdirectory).

There now is a WITH_SSE2 cmake option, which is explained in the
top-level CMakeLists.

Let me know if you have trouble with any aspect of Eigen2. If you
build the docs from SVN (cmake -DBUILD_DOC=ON, make), you’ll see the
beginning of a “Quick Start Guide”. Even without building docs
yourself, you can see the API docs of alpha7 there:
Eigen: Main Page

I’d like to show you one of the places that benefited dramatically from
the move from Eigen 1 to Eigen 2. I hope this helps you take full
advantage of Eigen 2.

Let’s go to libavogadro/src/cylinder.cpp:

Here is the old Cylinder::draw() using Eigen 1:
{
Vector3d axis = end2 - end1;

Vector3d axisNormalized = axis.normalized();
Vector3d ortho1, ortho2;
ortho1.loadOrtho(axisNormalized);
ortho1 *= radius;
axisNormalized.cross( ortho1, &ortho2 );

// construct the 4D transformation matrix
Matrix4d matrix;

matrix(0, 0) = ortho1(0);
matrix(1, 0) = ortho1(1);
matrix(2, 0) = ortho1(2);
matrix(3, 0) = 0.0;

matrix(0, 1) = ortho2(0);
matrix(1, 1) = ortho2(1);
matrix(2, 1) = ortho2(2);
matrix(3, 1) = 0.0;

matrix(0, 2) = axis(0);
matrix(1, 2) = axis(1);
matrix(2, 2) = axis(2);
matrix(3, 2) = 0.0;

matrix(0, 3) = end1(0);
matrix(1, 3) = end1(1);
matrix(2, 3) = end1(2);
matrix(3, 3) = 1.0;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.array() );
glCallList( d->displayList );
glPopMatrix();
}

Here is the new Cylinder::draw() using Eigen 2. Notice how expression
templates allow to perform all vector operations in place, directly on
the blocks of the matrix, removing the need to first construct these
vectors and then copy them to blocks of the matrix.
{
// construct the 4D transformation matrix
Eigen::Matrix4d matrix;
matrix.row(3) << 0, 0, 0, 1;
matrix.block<3,1>(0,2) = end2 - end1; // the axis

Vector3d axisNormalized = matrix.block<3,1>(0,2).normalized();
matrix.block<3,1>(0,0) = axisNormalized.unitOrthogonal() * radius;
matrix.block<3,1>(0,1) = axisNormalized.cross(matrix.block<3,1>(0,0));
matrix.block<3,1>(0,3) = end1;

//now we can do the actual drawing !
glPushMatrix();
glMultMatrixd( matrix.data() );
glCallList( d->displayList );
glPopMatrix();
}

OK, finally, I’d like to take this occasion to draw your attention on
a couple of misc things that I fixed.

a) in Color, we were using glColor4fv in the apply() method but the
components were not stored as an array, hence there was no guarantee
that they would be adjacent in memory. My fault really, I wrote that
code a long time ago.

b) in GLPainter, you often used the gl methods like glVertex3d()
instead of glVertex3dv(). Remember, the ‘v’ variants are faster! Since
our data is generally stored as vectors, they’re also easier to call
and less error-prone.

By the way, i also made GLPainter use more Color::apply() instead of
glColor4f(r,g,b,a).

c) In order to apply a translation to a vector, you don’t need to
construct a 4x4 transformation matrix and multiply your vector by it.
I saw a lot of that in our source code. Applying a translation is just
adding two vectors. If you have a vector Position and want to apply to
it a translation by vector Displacement, the result is just Position +
Displacement. That’s just 3 FLOPs instead of about 30.

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move
Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.

Replying to self…

I just thought to myself: “Perhaps Eigen could be made clever enough
to understand that with Vector3d, for certain operations, the two
first coords can be handled as a single packet, and then there remains
the 3rd coord to handle separately. That would enable partial
vectorization without any overhead”.

And, I found that I was wrong, so I explain why just in case someone
else has the same idea:

In order for this to work, the vector must already be 128-bit aligned.
In terms of memory usage, requesting 128-bit alignment is almost the
same as requesting 128-bit memory allocation. In most cases, the same
amount of memory would be wasted… for poorer results.

Cheers,
Benoit

Quoting jacob@math.jussieu.fr:

Quoting Geoffrey Hutchison geoff.hutchison@gmail.com:

On Aug 26, 2008, at 3:51 PM, jacob@math.jussieu.fr wrote:

OK let me explain better the problem. ‘vector’ is a special keyword
used in AltiVec vectorization. But ‘vector’ is a also a class template
in namespace std. Somehow, in the setup of Avogadro, the two conflict
together.

Well, then in the Avogadro code, we should take out “using” for “std”
and add explicit namespace for std::vector.

Hm I have written to Konstantinos to ask him if there isn’t an
alternative to the “vector” keyword for vectorization. For SSE, there
is, so I hope that for AltiVec too.

Then I’m not 100% what exactly is causing trouble in Avogadro. I don’t
see where the “using namespace std;” is and I would rather first see
if we can change Eigen so it doesn’t trigger such problems.

128 bits i.e, 2 double’s so operations with Vector2d, Vector4d and
Vector4f are well optimized, but not Vector3d.

Are you saying that we should use Vector4d or Vector4f internally and
ignore the extra data?

Basically, I consider this to be Eigen’s work, not Avogadro’s. So when
I have time I might work at adding the feature to Eigen, to make 3D
vectors 128-bit aligned, and so enable vectorization for them ignoring
the gaps. By itself this is rather trivial, but a few packet
instructions are going to be broken in this scheme so we must make
sure to avoid them.

Avogadro should not have to implement that. If/when I implement that,
I’ll tell you how to enable it (a compile-time switch). It shouldn’t
require any change in Avogadro’s code. The whole point of Eigen is to
abstract that.

This won’t be a “revolution” for avogadro:

  • it would increase memory usage of geometric objects by +33%
  • since avogadro uses double precision, it would only reduce the
    number of flops from 3 to 2, so the max possible speed improvement is
    +50%
  • if avogadro switches to single precision then it can hope for x3
    speed improvement, but then since openbabel is definitely keeping
    double precision there would be the cost of float/double conversions
    which could outweigh that.
  • avogadro is probably spending a large part of its time waiting for
    OpenGL rendering. I don’t know how much time is spent in Eigen.
  • for the heavier numerical operations such as force fields, as
    discussed with Tim, the vectorization works very well already. For
    example, the other day, Tim had an array of n Vector3d’s. He stored it
    as a Eigen::Matrix<double,3,Eigen::Dynamic> and Eigen was
    automatically understanding that for the operations that he was doing,
    the matrix could be understood as a single vector of length 3*n
    instead of n vectors of size 3. The result was very good vectorization
    (x2 speed improvement, the maximum with double’s).

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.

Again replying to self to clarify an important point.

These vectorization issues depending on size are ONLY with FIXED-SIZE
vectors and matrices.

For dynamic-size objects, we vectorize ANY size by vectorizing the
“aligned part” and leaving a small “unaligned part” not vectorized. As
soon as sizes are big enough (say >10) the unaligned part becomes very
small compared to the aligned part and this works very well. It adds a
bit of runtime logic, i.e. the determination of what can be vectorized
is partly done at runtime, but it is definitely worth it and becomes
negligible for big enough sizes (again, >10 should be enough).

That’s why in Tim’s example, the 3*n operation is very well vectorized
regardless of n (it does not have to be a multiple of 2 or 4).

To summarize:
FIXED SIZE:
2f, 3f, 3d: not vectorizable (except certain operations on Matrix2f
which amount to Vector4f). Still very fast (like Eigen1 + expression
templates + far less costly asserts)
2d, 4f, 4d: completely vectorizable

DYNAMIC SIZE:
Any size is vectorizable (except of course when it’s smaller than 2d
or 4f, but dynamic-size is really not intended for such tiny sizes).
There is small runtime overhead, but it only penalizes significantly
very small sizes, for which dynamic size is slow anyway (prevents loop
unrolling, etc).

Cheers,
Benoit

Quoting jacob@math.jussieu.fr:

Replying to self…

I just thought to myself: “Perhaps Eigen could be made clever enough
to understand that with Vector3d, for certain operations, the two
first coords can be handled as a single packet, and then there remains
the 3rd coord to handle separately. That would enable partial
vectorization without any overhead”.

And, I found that I was wrong, so I explain why just in case someone
else has the same idea:

In order for this to work, the vector must already be 128-bit aligned.
In terms of memory usage, requesting 128-bit alignment is almost the
same as requesting 128-bit memory allocation. In most cases, the same
amount of memory would be wasted… for poorer results.

Cheers,
Benoit

Quoting jacob@math.jussieu.fr:

Quoting Geoffrey Hutchison geoff.hutchison@gmail.com:

On Aug 26, 2008, at 3:51 PM, jacob@math.jussieu.fr wrote:

OK let me explain better the problem. ‘vector’ is a special keyword
used in AltiVec vectorization. But ‘vector’ is a also a class template
in namespace std. Somehow, in the setup of Avogadro, the two conflict
together.

Well, then in the Avogadro code, we should take out “using” for “std”
and add explicit namespace for std::vector.

Hm I have written to Konstantinos to ask him if there isn’t an
alternative to the “vector” keyword for vectorization. For SSE, there
is, so I hope that for AltiVec too.

Then I’m not 100% what exactly is causing trouble in Avogadro. I don’t
see where the “using namespace std;” is and I would rather first see
if we can change Eigen so it doesn’t trigger such problems.

128 bits i.e, 2 double’s so operations with Vector2d, Vector4d and
Vector4f are well optimized, but not Vector3d.

Are you saying that we should use Vector4d or Vector4f internally and
ignore the extra data?

Basically, I consider this to be Eigen’s work, not Avogadro’s. So when
I have time I might work at adding the feature to Eigen, to make 3D
vectors 128-bit aligned, and so enable vectorization for them ignoring
the gaps. By itself this is rather trivial, but a few packet
instructions are going to be broken in this scheme so we must make
sure to avoid them.

Avogadro should not have to implement that. If/when I implement that,
I’ll tell you how to enable it (a compile-time switch). It shouldn’t
require any change in Avogadro’s code. The whole point of Eigen is to
abstract that.

This won’t be a “revolution” for avogadro:

  • it would increase memory usage of geometric objects by +33%
  • since avogadro uses double precision, it would only reduce the
    number of flops from 3 to 2, so the max possible speed improvement is
    +50%
  • if avogadro switches to single precision then it can hope for x3
    speed improvement, but then since openbabel is definitely keeping
    double precision there would be the cost of float/double conversions
    which could outweigh that.
  • avogadro is probably spending a large part of its time waiting for
    OpenGL rendering. I don’t know how much time is spent in Eigen.
  • for the heavier numerical operations such as force fields, as
    discussed with Tim, the vectorization works very well already. For
    example, the other day, Tim had an array of n Vector3d’s. He stored it
    as a Eigen::Matrix<double,3,Eigen::Dynamic> and Eigen was
    automatically understanding that for the operations that he was doing,
    the matrix could be understood as a single vector of length 3*n
    instead of n vectors of size 3. The result was very good vectorization
    (x2 speed improvement, the maximum with double’s).

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options


This message was sent using IMP, the Internet Messaging Program.

Hi,

It is really progressing. I updated to eigen rev 853085 since
I was away for the day.

Now I get this:

Linking CXX shared library libavogadro.dylib
ld: duplicate symbol Eigen::operator<<(std::basic_ostream<char,
std::char_traits >&, unsigned int __vector const&)in CMakeFiles/
avogadro-lib.dir/cylinder.o and CMakeFiles/avogadro-lib.dir/camera.o

collect2: ld returned 1 exit status
make[2]: *** [libavogadro/src/libavogadro.0.8.2.dylib] Error 1
make[1]: *** [libavogadro/src/CMakeFiles/avogadro-lib.dir/all] Error 2
make: *** [all] Error 2

A missing include or something similar ?

The problem now seems to be in avogadro.

Thanks a lot for your fast reactions to this problem !

Cheers,

Louis

Le 27 août 08 à 01:27, jacob@math.jussieu.fr a écrit :

Hi,

This is now fixed in Eigen revision 852991.

The fix was to replace ‘vector’ by ‘__vector’. Please let me know if
there is still a problem.

And, great news about the 13 translations !

Thanks,
Benoit

Quoting Louis Ricard louis.ricard@polytechnique.edu:

Hi,

It is really progressing. I updated to eigen rev 853085 since
I was away for the day.

Now I get this:

Thanks for reporting, there were missing “inline” keywords in Eigen’s
AltiVec code, so these symbols were indeed getting duplicated.

Fixed in revision 853519.

Thanks a lot for your fast reactions to this problem !

You’re welcome,

Cheers,
Benoit


This message was sent using IMP, the Internet Messaging Program.

Hi all,

On a G5 Mac, after updating Eigen to Benoît’s latest revision,
Avogadro compiles and runs O.K.

But crashes when saving.

Louis

Great!

Anybody else still following this thread? This is not Eigen’s bug, the crash
happens in OBConversion.

Louis, if nobody replies perhaps start a new thread without ‘eigen’ in the
name :wink:

Cheers,
Benoit

On Thursday 28 August 2008 11:56:20 Louis Ricard wrote:

Hi all,

On a G5 Mac, after updating Eigen to Benoît’s latest revision,
Avogadro compiles and runs O.K.

But crashes when saving.

Louis