주어진 차수와 샘플 포인트(x, y, z)의 Vandermonde 행렬을 생성하려면 Python Numpy에서 polynomial.polyvander3d()를 사용합니다. 이 메서드는 각도 deg 및 샘플 포인트(x, y, z)의 의사 Vandermonde 행렬을 반환합니다. 매개변수 x, y, z는 모두 같은 모양의 점 좌표 배열입니다. dtypes는 요소가 복잡한지 여부에 따라 float64 또는 complex128로 변환됩니다. 스칼라는 1차원 배열로 변환됩니다. 매개변수 deg는 [x_deg, y_deg, z_deg] 형식의 최대 각도 목록입니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
import numpy as np from numpy.polynomial.polynomial import polyvander3d
numpy.array() 메서드를 사용하여 동일한 모양의 점 좌표 배열을 만듭니다. -
x = np.array([1.5, 2.3]) y = np.array([3.7, 4.4]) z = np.array([5.3, 6.6])
배열 표시 -
print("Array1...\n",x) print("\nArray2...\n",y) print("\nArray3...\n",z)
데이터 유형 표시 -
print("\nArray1 datatype...\n",x.dtype) print("\nArray2 datatype...\n",y.dtype) print("\nArray3 datatype...\n",z.dtype)
치수 확인 -
print("\nDimensions of Array1...\n",x.ndim) print("\nDimensions of Array2...\n",y.ndim) print("\nDimensions of Array3...\n",z.ndim)
모양 확인 -
print("\nShape of Array1...\n",x.shape) print("\nShape of Array2...\n",y.shape) print("\nShape of Array3...\n",z.shape)
주어진 차수와 샘플 포인트(x, y, z)의 Vandermonde 행렬을 생성하려면 polynomial.polyvander3d() -
x_deg, y_deg, z_deg = 2, 3, 4 print("\nResult...\n",polyvander3d(x,y, z, [x_deg, y_deg, z_deg]))
예시
import numpy as np from numpy.polynomial.polynomial import polyvander3d # Create arrays of point coordinates, all of the same shape using the numpy.array() method x = np.array([1.5, 2.3]) y = np.array([3.7, 4.4]) z = np.array([5.3, 6.6]) # Display the arrays print("Array1...\n",x) print("\nArray2...\n",y) print("\nArray3...\n",z) # Display the datatype print("\nArray1 datatype...\n",x.dtype) print("\nArray2 datatype...\n",y.dtype) print("\nArray3 datatype...\n",z.dtype) # Check the Dimensions print("\nDimensions of Array1...\n",x.ndim) print("\nDimensions of Array2...\n",y.ndim) print("\nDimensions of Array3...\n",z.ndim) # Check the Shape print("\nShape of Array1...\n",x.shape) print("\nShape of Array2...\n",y.shape) print("\nShape of Array3...\n",z.shape) # To generate a Vandermonde matrix of given degree and sample points (x, y, z)., use the polynomial.polyvander3d() in Python Numpy x_deg, y_deg, z_deg = 2, 3, 4 print("\nResult...\n",polyvander3d(x,y, z, [x_deg, y_deg, z_deg]))
출력
Array1... [1.5 2.3] Array2... [3.7 4.4] Array3... [5.3 6.6] Array1 datatype... float64 Array2 datatype... float64 Array3 datatype... float64 Dimensions of Array1... 1 Dimensions of Array2... 1 Dimensions of Array3... 1 Shape of Array1... (2,) Shape of Array2... (2,) Shape of Array3... (2,) Result... [[1.00000000e+00 5.30000000e+00 2.80900000e+01 1.48877000e+02 7.89048100e+02 3.70000000e+00 1.96100000e+01 1.03933000e+02 5.50844900e+02 2.91947797e+03 1.36900000e+01 7.25570000e+01 3.84552100e+02 2.03812613e+03 1.08020685e+04 5.06530000e+01 2.68460900e+02 1.42284277e+03 7.54106668e+03 3.99676534e+04 1.50000000e+00 7.95000000e+00 4.21350000e+01 2.23315500e+02 1.18357215e+03 5.55000000e+00 2.94150000e+01 1.55899500e+02 8.26267350e+02 4.37921695e+03 2.05350000e+01 1.08835500e+02 5.76828150e+02 3.05718920e+03 1.62031027e+04 7.59795000e+01 4.02691350e+02 2.13426415e+03 1.13116000e+04 5.99514801e+04 2.25000000e+00 1.19250000e+01 6.32025000e+01 3.34973250e+02 1.77535822e+03 8.32500000e+00 4.41225000e+01 2.33849250e+02 1.23940102e+03 6.56882543e+03 3.08025000e+01 1.63253250e+02 8.65242225e+02 4.58578379e+03 2.43046541e+04 1.13969250e+02 6.04037025e+02 3.20139623e+03 1.69674000e+04 8.99272202e+04] [1.00000000e+00 6.60000000e+00 4.35600000e+01 2.87496000e+02 1.89747360e+03 4.40000000e+00 2.90400000e+01 1.91664000e+02 1.26498240e+03 8.34888384e+03 1.93600000e+01 1.27776000e+02 8.43321600e+02 5.56592256e+03 3.67350889e+04 8.51840000e+01 5.62214400e+02 3.71061504e+03 2.44900593e+04 1.61634391e+05 2.30000000e+00 1.51800000e+01 1.00188000e+02 6.61240800e+02 4.36418928e+03 1.01200000e+01 6.67920000e+01 4.40827200e+02 2.90945952e+03 1.92024328e+04 4.45280000e+01 2.93884800e+02 1.93963968e+03 1.28016219e+04 8.44907045e+04 1.95923200e+02 1.29309312e+03 8.53441459e+03 5.63271363e+04 3.71759100e+05 5.29000000e+00 3.49140000e+01 2.30432400e+02 1.52085384e+03 1.00376353e+04 2.32760000e+01 1.53621600e+02 1.01390256e+03 6.69175690e+03 4.41655955e+04 1.02414400e+02 6.75935040e+02 4.46117126e+03 2.94437303e+04 1.94328620e+05 4.50623360e+02 2.97411418e+03 1.96291536e+04 1.29552414e+05 8.55045929e+05]]