Bug 400 - min/max with a scalar
: min/max with a scalar
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - general
: unspecified
: All All
: Normal enhancement
Assigned To: Nobody
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-01-05 22:47 UTC by abachrach
Modified: 2012-01-22 18:37 UTC (History)
4 users (show)



Attachments
a patch to implement scalar min/max (7.13 KB, patch)
2012-01-06 16:17 UTC, abachrach
no flags Details | Diff | Splinter Review
A new patch that implements the features and has tests (13.97 KB, patch)
2012-01-11 17:03 UTC, abachrach
no flags Details | Diff | Splinter Review

Description abachrach 2012-01-05 22:47:13 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 use the min/max operator with a
scalar argument, as in:
Array4d x;
x<<1,-2,3,4;
x.max(0);
Comment 1 abachrach 2012-01-06 16:17:55 UTC
Created attachment 243 [details] [review]
a patch to implement scalar min/max

Please find attached a patch that implements this feature.

As gael suggested, I made the method an alias to calling min/max with a
constant array.

The patch also includes a scalar argument method for the matrix class in
cwiseMin/Max.

thanks!
Comment 2 abachrach 2012-01-06 16:19:59 UTC
Oh yah, and everything seems happy with running "make check".
Comment 3 Gael Guennebaud 2012-01-06 23:41:04 UTC
Comment on attachment 243 [details] [review]
a patch to implement scalar min/max

Review of attachment 243 [details] [review]:
-----------------------------------------------------------------

sounds good except that it's missing testing, see test/array.h (for min/max)
and test/array_for_matrix.cpp (for cwiseMin/Max)
Comment 4 abachrach 2012-01-11 15:10:00 UTC
right... I had looked into writing tests, but wasn't sure where it should go
and then didn't.

I'll do that shortly.

-=Abe
Comment 5 abachrach 2012-01-11 17:03:55 UTC
Created attachment 246 [details] [review]
A new patch that implements the features and has tests

Created a new patch that implements the scalar min/max functions along with the
necessary testing routines.
Comment 6 Jitse Niesen 2012-01-22 18:22:55 UTC
I cannot see anything wrong with it, so I committed the patch (changeset
ec430a9cb055).

Thanks very much for your help.
Comment 7 abachrach 2012-01-22 18:37:24 UTC
glad to be of service!

thanks,
-=Abe

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