[Python] numpy module - matrix operation
import numpy as np
multiplication
For Vector
np.dot( ndarray_a, ndarray_b ) , np.inner( ndarray_a, ndarray_b )
- inner product
np.outer( ndarray_a, ndarray_b )
- outer product
np.cross( ndarray_a, ndarray_b )
For Matrix
np.dot( ndarray_a, ndarray_b ), np.matmult( ndarray_a, ndarray_b), ndarray_a @ ndarray_b
- matrix multiplication
np.inner( ndarray_a, ndarray_b )
- inner product
numpy module안에 matrix data type도 있어서 ndarray처럼 사용 가능
대신 matrix data type에서는 * 이 dot( ) 과 동일한 기능 수행
from numpy.linalg import inv
ainv = inv( ndarray_a ) or np.linalg.inv( ndarray_a )
np.linalg.det( ndarray_a )
3D matrix에서는 2D matrix 별로 determinant / inverse를 구해서 return함
np.linalg.eig( ndarray_a )
- eigenvalue / eigenvector 동시 return
spectral decomposition
SVD
np.allclose( ndarray_a, ndarray_b )
- Returns True if two arrays are element-wise equal within a tolerance