On Fri, 30 Apr 2010 17:23:33 -0400, Jérôme M. Berger <jeber...@free.fr>
wrote:
Robert Jacques wrote:
On Thu, 29 Apr 2010 19:16:49 -0400, Gareth Charnock
<gareth....@gmail.com> wrote:
Jérôme M. Berger wrote:
Gareth Charnock wrote:
PS: Okay so I just had a looked at the matrix and vector classes in
Ogre3D and irrlicht. Looks like they both define v*v as element wise
multiplication but m*m is matrix multiplication. That just seems even
more inconsistent.
Eigen (http://eigen.tuxfamily.org/ ) uses '*' for the matrix
multiplication. v*v is an error (incompatible shapes). Element wise
operations can be done like this: v.cwise()*v
Jerome
That's an very impressive looking library if even half of what they
claim is true. I can't believe I've missed this for so long (found the
boost matrix library, blitz++, the matrix template library, FLENS,
something called armadillo but not eigen. I do believe all my C++
linear algebra woes are over.
Eigen seems to treat vectors as 1 by n matrices and if you do this you
get the matrix-vector product and the dot product for free as these
are all the same operation. Probably v^T*v would be the dot product.
Expression templates should make these operations efficient.
Actually, express templates, though they give nice syntax result in a
lot of temporaries, which hurt performance. Check out Don's BLADE
library and the associated talks and posts.
According to the documentation, Eigen expression templates do not
result in temporaries, except for multiplication. And even then, you
can remove the temporaries by using the .lazy function in Eigen2 or
the .noalias() function in the upcoming Eigen3:
http://eigen.tuxfamily.org/dox-devel/Eigen2ToEigen3.html#LazyVsNoalias
An yes, it is very impressive :) and very comfortable to use. I had
seen about the same selection as you before discovering Eigen and
moving to it. The only drawback is that it currently doesn't
multithread.
Jerome
No, according to the documentation, Eigen expression templates do not
result in any temporary vectors. They do however, result in a a lot of
stack temporaries. And stack temporaries of stack temporaries. The
overhead of using expression templates has generally been ignored in CS,
which is why when I first saw Don's BLADE library and talk it was so
refreshing. The weaknesses of expression templates was also a major reason
for the inclusion of array ops as a language feature.