![]() Registered Member ![]()
|
I use maxCoeff to find the maximum of a vector, which can have several equal maxima. In this case, the max operation is obviously not well-defined and Eigen picks one of the solutions, which generally is fine.
However, when using different compilers/compiler options, Eigen's maxCoeff seems to pick different values, which can make testing difficult (I had the problem compiling code with cython gcc vs gcc in xcode - I have not found the exact switch that causes the difference, though). While not really being a bug, I think it could be useful if there was a default behaviour for the max/min operations when there is several max/min (e.g. pick the one with the smallest index). This is also the matlab behaviour. Would that make sense given the implementation of eigen? |
![]() Moderator ![]()
|
Can you be more specific about the compiler options that change the behavior of maxCoeff. It should really always return the first hit (i.e., the one with lowest index).
|
![]() Registered Member ![]()
|
I think I've narrowed it down to the following:
GCC is fine and picks the first value, the problem is when I use XCode, which uses either LLVM GCC 4.2 or Apple LLVM 4.1, both do not always pick the first value. Compiler options don't seem to make a difference. |
![]() Moderator ![]()
|
Sorry but I cannot reproduce with i686-apple-darwin11-llvm-g++-4.2 (and I don't have LLVM4.1). Looking at the code, I don't see how it could returns something different than the first occurrence.
|
![]() Registered Member ![]()
|
thanks for the clarification, I don't see it either in the code. Also, I can't make a simple test case where the problem occurs, although I have checked that it does in my original program.
I suppose the problem could be that when using different compilers the numbers are different by a tiny amount, such that different ones look bigger than others for different compilers - that would then be a precision issue and not a problem with maxCoeff. Sorry about the confusion...maybe the documentation could state explicitly that max and minCoeff return the first value of equals? |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]