|
Registered Member
|
Hi, can you please have a look at the following code snippet? The problem manifests in test2 where I try to assign a scalar value to a ColXpr.
Thanks, Martin
Output:
Last edited by martin_ on Tue Jun 17, 2014 7:01 am, edited 1 time in total.
|
|
Moderator
|
You can uses arrays or the comma initializer (http://eigen.tuxfamily.org/dox-devel/gr ... ation.html). e.g., vec.col(c) << c;
|
|
Registered Member
|
Thanks a lot for the answer. Using the comma initializer assigns the value correctly.
However my problem is that this code compiles as well but does not assign the value correctly (I have edited my original post to make this more clear).
Maybe here is a better example to express my problem. I am using the same syntax for the vec and mat. The assignment to the matrix works but the one to the vector doesn't:
Output
|
|
Moderator
|
This is because Matrix <int, 1, 1> (c) calls that constructor: http://eigen.tuxfamily.org/dox/classEig ... 7aaa077c4b.
If you omit -DNDEBUG, then you should get an assert. I admit that's confusing. We have the same issue for 2D vectors Eigen::Matrix <int, 2, 1>(rows,cols) versus Eigen::Matrix <int, 2, 1>(x,y) for which we have a workaround to get the expected behavior. Somehow, we did not though about the extremely rare 1x1 case. |
|
Registered Member
|
You are right, I was compiling in Release mode. In debug it asserts.
Thanks for the explanation. Now I understand the problem. |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]