This bugzilla service is closed. All entries have been migrated to
Bug 400 - min/max with a scalar
Summary: min/max with a scalar
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: unspecified
Hardware: All All
: Normal enhancement
Assignee: Nobody
Depends on:
Reported: 2012-01-05 22:47 UTC by abachrach
Modified: 2019-12-04 11:21 UTC (History)
4 users (show)

a patch to implement scalar min/max (7.13 KB, patch)
2012-01-06 16:17 UTC, abachrach
no flags Details | Diff
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

Description abachrach 2012-01-05 22:47:13 UTC
Reminder for implementing the features requested in this thread:

Basically, it would be nice to be able to use the min/max operator with a scalar argument, as in:
Array4d x;
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.

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.

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!

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

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