在 Python 中生成厄米多項式和 x、y、z 浮點型陣列點的偽範德蒙德矩陣
要生成厄米多項式和 x、y、z 樣本點的偽範德蒙德矩陣,請在 Python NumPy 中使用 hermite.hermvander3d()。此方法返回偽範德蒙德矩陣。引數 x、y、z 是點座標陣列,形狀相同。資料型別將轉換為 float64 或 complex128,具體取決於是否存在複數元素。標量將轉換為一維陣列。引數 deg 是最大次數列表,格式為 [x_deg, y_deg, z_deg]。
步驟
首先,匯入所需的庫:
import numpy as np from numpy.polynomial import hermite as H
使用 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 樣本點的偽範德蒙德矩陣,請在 Python NumPy 中使用 hermite.hermvander3d():
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",H.hermvander3d(x,y,z, [x_deg, y_deg, z_deg]))示例
import numpy as np
from numpy.polynomial import hermite as H
# 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 of both the arrays
print("\nDimensions of Array1...\n",x.ndim)
print("\nDimensions of Array2...\n",y.ndim)
print("\nDimensions of Array3...\n",z.ndim)
# Check the Shape of both the arrays
print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
print("\nShape of Array3...\n",z.shape)
# To generate a pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points, use the hermite.hermvander3d() in Python Numpy
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",H.hermvander3d(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 1.06000000e+01 1.10360000e+02 1.12741600e+03 1.12884496e+04 7.40000000e+00 7.84400000e+01 8.16664000e+02 8.34287840e+03 8.35345270e+04 5.27600000e+01 5.59256000e+02 5.82259360e+03 5.94824682e+04 5.95578601e+05 3.60824000e+02 3.82473440e+03 3.98205366e+04 4.06798751e+05 4.07314354e+06 3.00000000e+00 3.18000000e+01 3.31080000e+02 3.38224800e+03 3.38653488e+04 2.22000000e+01 2.35320000e+02 2.44999200e+03 2.50286352e+04 2.50603581e+05 1.58280000e+02 1.67776800e+03 1.74677808e+04 1.78447404e+05 1.78673580e+06 1.08247200e+03 1.14742032e+04 1.19461610e+05 1.22039625e+06 1.22194306e+07 7.00000000e+00 7.42000000e+01 7.72520000e+02 7.89191200e+03 7.90191472e+04 5.18000000e+01 5.49080000e+02 5.71664800e+03 5.84001488e+04 5.84741689e+05 3.69320000e+02 3.91479200e+03 4.07581552e+04 4.16377277e+05 4.16905021e+06 2.52576800e+03 2.67731408e+04 2.78743756e+05 2.84759126e+06 2.85120048e+07] [1.00000000e+00 1.32000000e+01 1.72240000e+02 2.22076800e+03 2.82806976e+04 8.80000000e+00 1.16160000e+02 1.51571200e+03 1.95427584e+04 2.48870139e+05 7.54400000e+01 9.95808000e+02 1.29937856e+04 1.67534738e+05 2.13349583e+06 6.28672000e+02 8.29847040e+03 1.08282465e+05 1.39613466e+06 1.77792827e+07 4.60000000e+00 6.07200000e+01 7.92304000e+02 1.02155328e+04 1.30091209e+05 4.04800000e+01 5.34336000e+02 6.97227520e+03 8.98966886e+04 1.14480264e+06 3.47024000e+02 4.58071680e+03 5.97714138e+04 7.70659794e+05 9.81408080e+06 2.89189120e+03 3.81729638e+04 4.98099340e+05 6.42221944e+06 8.17847005e+07 1.91600000e+01 2.52912000e+02 3.30011840e+03 4.25499149e+04 5.41858166e+05 1.68608000e+02 2.22562560e+03 2.90410419e+04 3.74439251e+05 4.76835186e+06 1.44543040e+03 1.90796813e+04 2.48960932e+05 3.20996558e+06 4.08777800e+07 1.20453555e+04 1.58998693e+05 2.07469203e+06 2.67499401e+07 3.40651057e+08]]
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP