Getting the location of the maximum coefficient of an Eigen C++ library Vector
c++, eigen
Solution
There is no sequence point between the 2 uses of `pos` in your line. The compiler is free to evaluate the second `pos` before calling `maxCoeff`. If you initialize `int pos = 42;` it will make it more obvious.
Problem
I came across a problem due to either my misunderstanding of the documentation, or a bug. I want to retrieve the position of the maximum coefficient of a vector: ``` #include <Eigen/Core> #include <iostream> int main(int argc, char *argv[]) { Eigen::Vector3f v; int pos; v << 1, 2, 3; std::cout << v.maxCoeff(&pos) << "\n" << "pos=" << pos << "\n"; return 0; } ``` the returned result (pos) is always zero, no matter where the maximum value is. Through debugging, I have seen that indeed the correct value (i, j) is computed in the visitor, but it seems that maxVisitor.col is returned instead of maxVisitor.row. This happens also with the latest mercurial version. Do you think it is a bug? Should I file a bug report?