sn42
R&D Job in Japan.
Topics
My Twitter
MATLAB と Numpy (ndarray) の行列操作の対応をまとめました。
MATLAB: documentation
Numpy: documentation
zeros(M,N)
ones(M,N)
np.zeros((M,N))
np.ones((M,N))
repmat(A, 5)
repmat(A, 5, 5)
np.repeat(A, 5)
np.tile(A, (5,5))
A'
reshape(A, 3, 2, 1)
A.T
np.transpose(A, (2,1,0))
sum(A, 'all')
sum(A)
sum(A, 2)
np.sum(A)
np.sum(A, axis=0)
np.sum(A, axis=1)
prod(A, 'all')
prod(A)
prod(A, 2)
np.prod(A)
np.prod(A, axis=0)
np.prod(A, axis=1)
A.*B
A*B
np.multiply(A, B)
A*B
A@B
np.dot(A,B)
kron(A, B)
np.kron(A,B)
A.^2
np.power(A, 2)
A^2
np.linalg.matrix_power(A, 2)
size(A, 1)
np.shape(A)[0]
find(A > 0)
np.where(A > 0)[0]
det(A)
np.linalg.det(A)
inv(A)
np.linalg.inv(A)
pinv(A)
np.linalg.pinv(A)
[V, W] = eig(A)
w, V = np.linalg.eig(arr)
W = np.diagonal(w)
[U, S, V] = svd(A)
U, s, V = np.linalg.svd(A)
S = np.diagonal(s)