This forum has been archived. All content is frozen. Please use KDE Discuss instead.

maxCoeff when equal

Tags: None
(comma "," separated)
jakjohnson
Registered Member
Posts
5
Karma
0

maxCoeff when equal

Mon Dec 31, 2012 3:07 pm
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?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: maxCoeff when equal

Sat Jan 05, 2013 10:47 pm
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).
jakjohnson
Registered Member
Posts
5
Karma
0

Re: maxCoeff when equal

Mon Jan 07, 2013 10:55 am
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: maxCoeff when equal

Mon Jan 07, 2013 9:13 pm
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.
jakjohnson
Registered Member
Posts
5
Karma
0

Re: maxCoeff when equal

Tue Jan 08, 2013 10:06 am
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?


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]