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. -- View this message in context: http://old.nabble.com/matrix-operation-tp27936387p27936387.html Sent from the Numpy-discussion mailing list archive at Nabble.com.
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
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}
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.
In [4]:C = numpy.minimum(A,B) In [5]:C Out[5]: array([[ 1, 3], [ 9, 12]])
17/03/10 @ 11:47 (-0700), thus spake gerardob:
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.
Try numpy.minimum: In [7]: np.minimum(A, B) Out[7]: array([[ 1, 3], [ 9, 12]])
Thanks.
-- View this message in context: http://old.nabble.com/matrix-operation-tp27936387p27936387.html Sent from the Numpy-discussion mailing list archive at Nabble.com.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
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@noaa.gov
Christopher Barker wrote:
In [32]: numpy.minimum(A,B)
wow! fifth to answer that one -- darn I'm slow! -Chris -- 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@noaa.gov
participants (6)
-
Christopher Barker -
Eric Firing -
Ernest Adrogué -
gerardob -
Ian Mallett -
Keith Goodman