[Numpy-discussion] matrix operation

Christopher Barker Chris.Barker at noaa.gov
Wed Mar 17 15:06:47 EDT 2010


gerardob wrote:
> Let A and B be two n x n matrices.
> 
> I would like to have another n x n  matrix C such that
> C_ij = min {A_ij, B_ij}

In [30]: A = numpy.array([[2,3],[10,12]])

In [31]: B = numpy.array([[1,4],[9,13]])

In [32]: numpy.minimum(A,B)
Out[32]:
array([[ 1,  3],
        [ 9, 12]])



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list