[eigen] odd behaviour of operator[] |

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

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...