선형 대수학에서 2D 배열의 행렬식을 계산하려면 Python Numpy에서 np.linalg.det()를 사용합니다. 첫 번째 매개변수인 a는 행렬식을 계산할 입력 배열입니다. 이 메서드는 의 행렬식을 반환합니다.
단계
먼저 필요한 라이브러리를 가져옵니다-
import numpy as np
배열 생성 -
arr = np.array([[ 5, 10], [12, 18]])
배열 표시 -
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) 선형 대수학에서 2D 배열의 행렬식을 계산하려면 Python에서 np.linalg.det()를 사용하십시오 -
print("\nResult...\n",np.linalg.det(arr)) 예
import numpy as np
# Create an array
arr = np.array([[ 5, 10], [12, 18]])
# 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 of a 2D array in linear algebra, use the np.linalg.det() in Python Numpy.
# The 1st parameter, a is the input array to compute determinants for.
# The method returns the determinant of a.
print("\nResult...\n",np.linalg.det(arr))의 행렬식을 반환합니다. 출력
Our Array... [[ 5 10] [12 18]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (2, 2) Result... -30.000000000000014