Re: [eigen] odd behaviour of operator[] |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] odd behaviour of operator[]*From*: Mark Borgerding <mark@xxxxxxxxxxxxxx>*Date*: Thu, 18 Jun 2009 13:54:05 -0400

Here's what I think is happening (anyone correct me if I'm wrong):

So "states[a,0]" is equivalent to "states[0]".

Andre Krause wrote:

dear list, today i coded a little code fragment and typed square braces instead of round ones: MatrixXf states(N, 3); for(int a=0;a < N;a++) { states[a, 0] = sin(0.1*a); states[a, 1] = sin(0.2*a); states[a, 2] = sin(0.3*a); } oddly enough, this code compiles fine and executes without asserts, but assigns strange values to the array. so this obviously does not work but the error is not catched by eigen2.0.2. of course, this way work MatrixXf states(N, 3); for(int a=0;a < N;a++) { states(a, 0) = sin(0.1*a); states(a, 1) = sin(0.2*a); states(a, 2) = sin(0.3*a); } might there be a way to detect the pitfall of accessing 2d matrixes with square braces ? at least, one could disable operator[] completely...

**References**:**[eigen] odd behaviour of operator[]***From:*Andre Krause

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] odd behaviour of operator[]** - Next by Date:
**Re: [eigen] odd behaviour of operator[]** - Previous by thread:
**[eigen] odd behaviour of operator[]** - Next by thread:
**Re: [eigen] odd behaviour of operator[]**

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