udacity / sdc-issue-reports

29 stars 6 forks source link

Using auto for Eigen expressions in CarND-MPC-Project and CarND-MPC-Quizzes #823

Closed dimaga closed 7 years ago

dimaga commented 7 years ago

It is recommended not to use C++11 auto with Eigen expressions: see http://eigen.tuxfamily.org/dox/TopicPitfalls.html However, it is widely used in https://github.com/udacity/CarND-MPC-Quizzes/blob/master/polyfit/src/main.cpp and https://github.com/udacity/CarND-MPC-Project/blob/master/src/main.cpp

domluna commented 7 years ago

@dimaga I believe the biggest use is in the polyfit function and, in that case, the result is exactly what we want. It's true you have to be careful when using auto with Eigen though.

For example:

auto Q = A.householderQr();
auto result = Q.solve(yvals);

the above works as we would expect but:

auto result = A.householderQr().solve(yvals);

does not.

Since the current setup works I see no reason to really change it but you bring up a good point nonetheless.