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

Travis Oliphant oliphant.travis at ieee.org
Tue Jun 20 14:58:54 EDT 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