This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 401 - obtain the coefficients of the indices for a row/colwise call to maxCoeff
Summary: obtain the coefficients of the indices for a row/colwise call to maxCoeff
Status: DECISIONNEEDED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.4 (development)
Hardware: All All
: Normal Feature Request
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on: 984
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-05 22:49 UTC by abachrach
Modified: 2019-12-04 11:22 UTC (History)
5 users (show)



Attachments

Description abachrach 2012-01-05 22:49:47 UTC
Reminder for implementing the features requested in this thread:
http://forum.kde.org/viewtopic.php?f=74&t=98384&sid=c5804c453b7e843d4488e7cbb3a2da2f

Basically, it would be nice to be able to get the indices of the min/max in each row in addition to the value

ie: 

  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
  test.rowwise().maxCoeff();
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
+1 

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();
or
  (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 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.

Note You need to log in before you can comment on or make changes to this bug.