[Numpy-discussion] matrix operation

Keith Goodman kwgoodman@gmail....
Wed Mar 17 13:53:31 CDT 2010


On Wed, Mar 17, 2010 at 11:47 AM, gerardob <gberbeglia@gmail.com> 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}
>
> Example:
> A = numpy.array([[2,3],[10,12]])
> B = numpy.array([[1,4],[9,13]])
>
> Output
>
> C = [[1,3],[9,12]]
>
> The function min(axis) of numpy seems to be only unary.
>
> Thanks.

>> numpy.minimum(A, B)
array([[ 1,  3],
       [ 9, 12]])

In ipython:

>> numpy.min [tab]
numpy.min          numpy.minimum      numpy.mintypecode


More information about the NumPy-Discussion mailing list