$ python
>>> import numpy as np
maximum
>>> np.maximum([1,2], [3,1]) # array([3, 2])
>>> np.maximum(0, [-1, 2, -2, 4]) # array([0, 2, 0, 4])
argmax
>>> np.argmax([1,3,4,2]) # 2
max
>>> a = np.array([[1,4],[2,3]])
>>> np.max(a, axis=0) # array([2, 4])
>>> np.max(a, axis=1) # array([4, 3])
diagonal
>>> a = np.arange(9).reshape(3,3) # array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
>>> a.diagonal() # array([0, 4, 8])
>>> np.fliplr(a).diagonal() # array([2, 4, 6])
allclose
行列が近似的に等しいか調べる
where
>>> test = np.array([True, False])
>>> np.where(test, 1, 2) # array([1, 2])