Scimath로 자연 로그를 계산하려면 Python Numpy에서 np.emath.log() 메서드를 사용합니다. 이 메서드는 x 값의 로그를 반환합니다. x가 스칼라이면 out이고 그렇지 않으면 배열이 반환됩니다. 첫 번째 매개변수 x는 로그가 필요한 값입니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
import numpy as np
array() 메서드를 사용하여 numpy 배열 만들기 -
arr = np.array([np.inf, -np.inf, np.exp(1), -np.exp(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)
scima로 자연 로그를 계산하려면 Python Numpy에서 np.emath.log() 메서드를 사용하십시오 -
print("\nResult (log)...\n",np.emath.log(arr)) 예시
import numpy as np
# Creating a numpy array using the array() method
arr = np.array([np.inf, -np.inf, np.exp(1), -np.exp(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 natural logarithm with scimath, use the np.emath.log() method in Python Numpy.
print("\nResult (log)...\n",np.emath.log(arr))의 메서드 출력
Our Array... [ inf -inf 2.71828183 -2.71828183] Dimensions of our Array... 1 Datatype of our Array object... float64 Shape of our Array object... (4,) Result (log)... [inf+0.j inf+3.14159265j 1.+0.j 1.+3.14159265j]