在 Python 中生成 Hermite 多項式和 x、y、z 樣本點的偽範德蒙德矩陣
要生成 Hermite 多項式和 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, 2]) y = np.array([3, 4]) z = np.array([5, 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)# 要生成 Hermite 多項式和 x、y、z 樣本點的偽範德蒙德矩陣,請使用 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, 2])
y = np.array([3, 4])
z = np.array([5, 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
# The method returns the pseudo-Vandermonde matrix.
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 2]
Array2...
[3 4]
Array3...
[5 6]
Array1 datatype...
int64
Array2 datatype...
int64
Array3 datatype...
int64
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.0000000e+00 1.0000000e+01 9.8000000e+01 9.4000000e+02 8.8120000e+03
6.0000000e+00 6.0000000e+01 5.8800000e+02 5.6400000e+03 5.2872000e+04
3.4000000e+01 3.4000000e+02 3.3320000e+03 3.1960000e+04 2.9960800e+05
1.8000000e+02 1.8000000e+03 1.7640000e+04 1.6920000e+05 1.5861600e+06
2.0000000e+00 2.0000000e+01 1.9600000e+02 1.8800000e+03 1.7624000e+04
1.2000000e+01 1.2000000e+02 1.1760000e+03 1.1280000e+04 1.0574400e+05
6.8000000e+01 6.8000000e+02 6.6640000e+03 6.3920000e+04 5.9921600e+05
3.6000000e+02 3.6000000e+03 3.5280000e+04 3.3840000e+05 3.1723200e+06
2.0000000e+00 2.0000000e+01 1.9600000e+02 1.8800000e+03 1.7624000e+04
1.2000000e+01 1.2000000e+02 1.1760000e+03 1.1280000e+04 1.0574400e+05
6.8000000e+01 6.8000000e+02 6.6640000e+03 6.3920000e+04 5.9921600e+05
3.6000000e+02 3.6000000e+03 3.5280000e+04 3.3840000e+05 3.1723200e+06]
[1.0000000e+00 1.2000000e+01 1.4200000e+02 1.6560000e+03 1.9020000e+04
8.0000000e+00 9.6000000e+01 1.1360000e+03 1.3248000e+04 1.5216000e+05
6.2000000e+01 7.4400000e+02 8.8040000e+03 1.0267200e+05 1.1792400e+06
4.6400000e+02 5.5680000e+03 6.5888000e+04 7.6838400e+05 8.8252800e+06
4.0000000e+00 4.8000000e+01 5.6800000e+02 6.6240000e+03 7.6080000e+04
3.2000000e+01 3.8400000e+02 4.5440000e+03 5.2992000e+04 6.0864000e+05
2.4800000e+02 2.9760000e+03 3.5216000e+04 4.1068800e+05 4.7169600e+06
1.8560000e+03 2.2272000e+04 2.6355200e+05 3.0735360e+06 3.5301120e+07
1.4000000e+01 1.6800000e+02 1.9880000e+03 2.3184000e+04 2.6628000e+05
1.1200000e+02 1.3440000e+03 1.5904000e+04 1.8547200e+05 2.1302400e+06
8.6800000e+02 1.0416000e+04 1.2325600e+05 1.4374080e+06 1.6509360e+07
6.4960000e+03 7.7952000e+04 9.2243200e+05 1.0757376e+07 1.2355392e+08]]
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP