This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 400

Summary: min/max with a scalar
Product: Eigen Reporter: abachrach
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: enhancement CC: abachrach, gael.guennebaud, jacob.benoit.1, jitseniesen
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
a patch to implement scalar min/max
none
A new patch that implements the features and has tests none

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]
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]
a patch to implement scalar min/max

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

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]
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
Comment 8 Nobody 2019-12-04 11:21:59 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/400.