Reply to topic

Problems with STL Containers

luensel
Registered Member
Posts
5
Karma
0

Problems with STL Containers

Tue Nov 06, 2012 10:22 am
Hello,

i have Problems with Eigen using STL Containers.
First, i followed this Eigen tutorial: http://eigen.tuxfamily.org/dox/TopicStlContainers.html. But it don't work for me. If i debug my code step by step, at the position, where i declare the vector, my programm crash with an debug error.

Console entry: assertion failed: rows >= 0 && <RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows>...

In release mode i get an unhandled exception.

I try the 2 described ways in the Eigen documentation.

1. std::vector<Eigen::Vector3d,Eigen::aligned_allocator<Eigen::Vector3d> > x;

2. #include <Eigen\StdVector>
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Vector3d)
.....
vector<Vector3d> x;

Nothing work for me.

I have no idea why . I use Windows 8 x64, Visual Studio 2010 and i tried Eigen 3.1.1, 3.1.2.

I hope someone can help me :D.

Thanks,
luensel

Last edited by luensel on Wed Nov 07, 2012 4:37 pm, edited 1 time in total.
Gabyx
Registered Member
Posts
10
Karma
0

Re: Problems with STL Containers

Wed Nov 07, 2012 9:01 am
Your Vector3d is not a fixed-size aligned type! : http://eigen.tuxfamily.org/dox/TopicFix ... zable.html
So no need to care about the STL Container and its Allocator!

You could use also a class

Code: Select all
class Data{
EIGEN_MAKE_ALIGNED_OPERATOR_NEW();

Vector4d a;
};

std::vector<Data> a;

And everything works fine I think :-)
Because every "a" is aligned in a class!
I use this often, this should work,

Could somebody tell me if this is correct :-? Thanks a lot!
luensel
Registered Member
Posts
5
Karma
0

Re: Problems with STL Containers

Wed Nov 07, 2012 10:03 am
Hello Gabyx,

I think your solution didn't work for me. My little sample looks like:

Code: Select all
#include <Eigen/Eigen>
#include <Eigen/StdVecor>

int main()
{
   Vector3d x1(-4, 3, 40), x2(9, -5, 80), x3(5, 5, 60);

   std::vector<Eigen::Vector3d,Eigen::aligned_allocator<Eigen::Vector3d> > x;  <--- At this step, my program crash

   x.push_back(x1);
   x.push_back(x2);
   x.push_back(x3);

   .....

   return 0;
}
Gabyx
Registered Member
Posts
10
Karma
0

Re: Problems with STL Containers

Wed Nov 07, 2012 1:38 pm
You can just

use std::vector<Vector3d> :

Vector3d is a fixed size vector which is not a multiple of 16 bytes and is there fore not aligned in memory!

Am I wrong?

And ehm, your program does not crash by me. It works with Eigen 3.2.1 and Ubuntu and GCC 4.4
luensel
Registered Member
Posts
5
Karma
0

Re: Problems with STL Containers

Wed Nov 07, 2012 4:22 pm
Yes i knew that it must work. I think there is something wrong with my Visual Studio 2010 or Windows 8 64x, but i don't know what.

At runtime with debug mode i get this failure: "Debug Error" and the following console entry: "assertion failed: rows >= 0 && <RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows>..."

In release mode i get an unhandled exception.

But when i compile my Program, everything is fine.

I hope someone can help me
Hauke
Registered Member
Posts
109
Karma
3
OS

Re: Problems with STL Containers

Thu Nov 08, 2012 11:25 am
Hi luensel,

your code is working over here. I tried with Eigen Hg revision 4938 (be5e3923d925) and MSVC 2010 Version 10.0.40219.1 SP1 Rel.

Which version are you using?

Regards,
Hauke
luensel
Registered Member
Posts
5
Karma
0

Re: Problems with STL Containers

Fri Nov 09, 2012 8:19 am
Hi Hauke,

i use the same Visual Studio Version like you.

Greetings,
luensel
luensel
Registered Member
Posts
5
Karma
0

Re: Problems with STL Containers

Fri Nov 09, 2012 8:42 am
Hey,

i found my mistake :D. I forgot a comma in the row before :D

Thanks all ^^.

 
Reply to topic

Bookmarks



Who is online

Registered users: alexweb, Baidu [Spider], Bing [Bot], dgraf, Exabot [Bot], ggael, Google [Bot], GreatEmerald, ken300, koriun, lazyit, netpalantir, numbchild, paulus3005, pbCyanide, rulet111, Tsukasa Buddha, valoriez, vascobasque, wolfi323, Yahoo [Bot], Zagupi