[SciPy-user] element-by-element max of two arrays?

Grant Edwards grante at visi.com
Tue Jun 20 14:05:20 CDT 2006

On 2006-06-20, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> Grant Edwards wrote:
>> There's got to be a simple way to do this, but I can't find it. 
>> How do I get an element-by-element max or min of two arrays?
>> For two NxM arrays A and B, I want an NxM array C where
>>    C[i,j] == max(A[i,j],B[i,j])
>> I had thought maybe max(A,B) would work, but it doesn't.

> C = numpy.maximum(A,B)

Well, that's a bit obvious. ;)

I had just figured out that array((A,B)).max(0) did what I
wanted, but that's a little opaque.

Grant Edwards                   grante             Yow!  .. I wonder if I
                                  at               ought to tell them about my
                               visi.com            PREVIOUS LIFE as a COMPLETE

More information about the SciPy-user mailing list