hypot ; hypotenuse(빗변)
numpy.hypot(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'hypot'>
np.hypot(3*np.ones((3, 3)), 4*np.ones((3, 3)))
array([[ 5., 5., 5.],
[ 5., 5., 5.],
[ 5., 5., 5.]])
pad(array, pad_width, mode='constant', **kwargs)
# 위쪽 3개행, 아래쪽 2개행, 왼쪽 2개열, 오른족 3개열 0으로 패딩합니다
a = [[3, 2], [2, 3]]
np.pad(a, ((3, 2), (2, 3)), 'minimum')
>>> array([[1, 1, 1, 2, 1, 1, 1],
[1, 1, 1, 2, 1, 1, 1],
[1, 1, 1, 2, 1, 1, 1],
[1, 1, 1, 2, 1, 1, 1],
[3, 3, 3, 4, 3, 3, 3],
[1, 1, 1, 2, 1, 1, 1],
[1, 1, 1, 2, 1, 1, 1]])
np.pad(aa, ((1,2),(3,4)), 'constant', constant_values=0)
??
https://numpy.org/doc/stable/reference/generated/numpy.pad.html
https://m.blog.naver.com/wideeyed/221665256911
ogrid/mgrid/meshgrid
- meshgrid란? coordinate matrices from coordinate vectors.
grid ; a pattern or structure made from horizontal and vertical lines crossing each other to form squares
2차원 메쉬그리드 ; 벡터 x 및 y 에 포함된 좌표를 바탕으로 2차원 그리드 좌표
3차원 메쉬그리드 ; 벡터 x, y, z로 정의되는 3차원 그리드 좌표
- ogrid ; an open multi-dimensional mesh-grid / all of the same dimension
- mgrid ; a dense multi-dimensional mesh-grid / only one dimension not equal to 1
*index가 matrix value와 같음
from numpy import ogrid
ogrid[-1:1:5j]
array([-1. , -0.5, 0. , 0.5, 1. ])
ogrid[0:5,0:5]
[array([[0],
[1],
[2],
[3],
[4]]), array([[0, 1, 2, 3, 4]])]
https://numpy.org/doc/stable/reference/generated/numpy.ogrid.html