Re: [eigen] Std Vector again

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


2009/6/26 Keir Mierle <mierle@xxxxxxxxx>:
> I started porting libmv to eigen 2.0.3, and got many assert failures due to
> putting vectorized eigen types into std::vectors or structs (which went into
> std::vectors). Oddly enough, it worked fine before.

Indeed there have been incompatible changes in this area.

> I first addressed this by using the eigen allocator,

That would work for any other STL container, but not for std::vector,
because of a design flaw in std::vector::resize which takes a
value_type by value. Whence the StdVector header. In Eigen 2.0.3, it
takes care of specifying the allocator for you. (Not in the
development branch though).

> Then I tried switching to using the eigen specialization in Eigen/StdVector.
> That ended up being worse, because suddenly my header files had to be
> included in a certain order, or there would be mysterious runtime breakage.

The only requirement should be: include <Eigen/StdVector> before
including <vector>. Actually, <Eigen/StdVector> takes care of
including <vector> for you. all you have to do is replace <vector> by
<Eigen/StdVector>.

> I consider it important that headers can be included in any order.

Yep, would be nice, but we didn't have a choice. This flaw is being
addressed in C++0x by the way.

> So now I'm left with a tree half-converted to 2.0.3. I'm not sure where to
> go next.

Just include <Eigen/StdVector> instead of <vector> everywhere. Don't
bother about allocators for now, with 2.0.3 you don't have to.

> What about having an Eigen::vector<> class?

people want to be able to use standard containers....

Benoit



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/