Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Python에서 x, y 및 z의 데카르트 곱에 대한 3차원 체비쇼프 급수 평가

<시간/>

x, y, z의 데카르트 곱에 대한 3차원 체비쇼프 급수를 평가하려면 Python에서 polynomial.chebgrid3d(x, y, z) 메서드를 사용하십시오. c의 차원이 3개 미만인 경우 3차원으로 만들기 위해 1차원이 해당 모양에 암시적으로 추가됩니다. 결과의 모양은 c.shape[3:] + x.shape + y.shape + z.shape입니다.

매개변수 x, y 및 z는 x, y 및 z의 데카르트 곱의 점에서 평가되는 3차원 계열입니다. x,`y`, 또는 z가 목록이나 튜플이면 먼저 ndarray로 변환하고, 그렇지 않으면 변경하지 않고 그대로 두고 ndarray가 아니면 스칼라로 처리합니다.

매개변수 c는 차수 i,j에 대한 계수가 c[i,j]에 포함되도록 정렬된 계수의 배열입니다. c의 차원이 2보다 큰 경우 나머지 인덱스는 여러 계수 세트를 열거합니다.

단계

먼저 필요한 라이브러리를 가져옵니다 -

import numpy as np
from numpy.polynomial import chebyshev as C

계수의 3D 배열 생성 -

c = np.arange(16).reshape(2,2,4)

배열 표시 -

print("Our Array...\n",c)

치수 확인 -

print("\nDimensions of our Array...\n",c.ndim)

데이터 유형 가져오기 -

print("\nDatatype of our Array object...\n",c.dtype)

모양 가져오기 -

print("\nShape of our Array object...\n",c.shape)

x, y, z의 데카르트 곱에 대한 3차원 체비쇼프 급수를 평가하려면 polynomial.chebgrid3d(x, y, z) 방법 -

를 사용하십시오.
print("\nResult...\n",C.chebgrid3d([1,2],[1,2],[1,2], c))

예시

import numpy as np
from numpy.polynomial import chebyshev as C

# Create a 3D array of coefficients
c = np.arange(16).reshape(2,2,4)

# Display the array
print("Our Array...\n",c)

# Check the Dimensions
print("\nDimensions of our Array...\n",c.ndim)

# Get the Datatype
print("\nDatatype of our Array object...\n",c.dtype)

# Get the Shape
print("\nShape of our Array object...\n",c.shape)

# To evaluate a 3-D Chebyshev series on the Cartesian product of x, y, z, use the polynomial.chebgrid3d(x, y, z) method in Python
print("\nResult...\n",C.chebgrid3d([1,2],[1,2],[1,2], c))
의 메서드

출력

Our Array...
[[[ 0 1 2 3]
   [ 4 5 6 7]]

[[ 8 9 10 11]
   [12 13 14 15]]]

Dimensions of our Array...
3

Datatype of our Array object...
int64

Shape of our Array object...
(2, 2, 4)

Result...
[[[ 120. 1240.]
   [ 196. 2004.]]

[[ 212. 2148.]
   [ 342. 3438.]]]