This bugzilla service is closed. All entries have been migrated to

Bug 401

Summary: obtain the coefficients of the indices for a row/colwise call to maxCoeff
Product: Eigen Reporter: abachrach
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: DECISIONNEEDED ---    
Severity: Feature Request CC: abachrach, chtz, gael.guennebaud, jacob.benoit.1, rmlarsen
Priority: Normal    
Version: 3.4 (development)   
Hardware: All   
OS: All   
Bug Depends on: 984    
Bug Blocks:    

Description abachrach 2012-01-05 22:49:47 UTC
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);
  ArrayXi inds;
  ArrayXd mtest = test.rowwise().maxCoeff(inds);
Comment 1 abachrach 2012-01-11 15:08:55 UTC
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...
Comment 2 Christoph Hertzberg 2013-11-18 14:52:47 UTC
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?
Comment 3 Rasmus Munk Larsen 2016-02-23 21:43:15 UTC

Christoph, I think having something like the maxCoeffIdx() you suggest (and perhaps a companion maxCoeffVal()) would be very helpful.
Comment 4 Christoph Hertzberg 2016-02-23 22:36:58 UTC
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();
Comment 5 Nobody 2019-12-04 11:22:12 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to'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: