Reminder for implementing the features requested in this thread:
Basically, it would be nice to be able to get the indices of the min/max in each row in addition to the value
ArrayXXd test= ArrayXXd::Random(5,5);
ArrayXd mtest = test.rowwise().maxCoeff(inds);
Just looked into attempting this, and unfortunately think it's well above my pay grade (for now :-p)
As far as I can tell, it'll require fairly major changes to the VectorWiseOp class because it currently only allows Unary Expressions. I could be (probably am) wrong though...
I'm afraid this is a bit complicated, due to lazy evaluation. At the moment
does nothing until it is assigned to a variable or individual coefficients are evaluated. That would be very non-intuitive for the requested variant.
Maybe an alternative would be to essentially return a pair of two arrays (essentially, this is what Matlab does) -- I don't know how well this can be implemented with lazy evaluation, though.
A simpler solution would be to simply implement a maxCoeffIdx() which only returns an index vector. Or maybe it's possible to disable lazy evaluation for this expression?
Christoph, I think having something like the maxCoeffIdx() you suggest (and perhaps a companion maxCoeffVal()) would be very helpful.
Another idea would be implementing the technique suggested in Bug 984, i.e. something like
vals, idxs = test.rowwise().maxCoeff();
(vals, idxs) = test.rowwise().maxCoeff();
-- GitLab Migration Automatic Message --
This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/401.