선형 대수학에서 행렬 스택에 대한 행렬식을 계산하려면 Python Numpy에서 np.linalg.det()를 사용합니다. 첫 번째 매개변수인 a는 행렬식을 계산할 입력 배열입니다. 이 메서드는 의 행렬식을 반환합니다.
단계
먼저 필요한 라이브러리를 가져옵니다. -
import numpy as np
배열 생성 -
arr = np.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]] ])
배열 표시 -
print("Our Array...\n",arr) 치수 확인 -
print("\nDimensions of our Array...\n",arr.ndim)
데이터 유형 가져오기 -
print("\nDatatype of our Array object...\n",arr.dtype) 모양 가져오기 -
print("\nShape of our Array object...\n",arr.shape) 선형 대수학에서 행렬 스택에 대한 행렬식을 계산하려면 Python에서 np.linalg.det()를 사용하십시오 -
print("\nResult (determinant)...\n",np.linalg.det(arr)) 예시
import numpy as np
# Create an array
arr = np.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]]])
# Display the array
print("Our Array...\n",arr)
# Check the Dimensions
print("\nDimensions of our Array...\n",arr.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",arr.dtype)
# Get the Shape
print("\nShape of our Array object...\n",arr.shape)
# To compute the determinant for a stack of matrices in linear algebra, use the np.linalg.det() in Python Numpy.
print("\nResult (determinant)...\n",np.linalg.det(arr))에서 np.linalg.det()를 사용합니다. 출력
Our Array... [[[1 2] [3 4]] [[1 2] [2 1]] [[1 3] [3 1]]] Dimensions of our Array... 3 Datatype of our Array object... int64 Shape of our Array object... (3, 2, 2) Result (determinant)... [-2. -3. -8.]