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

Travis Oliphant oliphant.travis at ieee.org
Tue Jun 20 13:58:54 CDT 2006


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)



More information about the SciPy-user mailing list