在Python中生成Hermite_e多项式和x、y、z浮点数组的伪Vandermonde矩阵
要生成Hermite_e多项式和x、y、z样本点的伪Vandermonde矩阵,请使用Python Numpy中的hermite_e.hermevander3d()方法。该方法返回伪Vandermonde矩阵。参数x、y、z是具有相同形状的坐标点数组。元素的数据类型将根据是否存在复数来转换为float64或complex128。标量将被转换为1维数组。参数deg是形式为[x_deg, y_deg, z_deg]的最大度数的列表。
步骤
首先,导入所需的库−
import numpy as np
from numpy.polynomial import hermite_e 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)
生成Hermite_e多项式和x、y、z样本点的伪Vandermonde矩阵,可以使用Python中的hermite_e.hermevander3d()函数。
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",H.hermevander3d(x,y,z, [x_deg, y_deg, z_deg]))
示例
import numpy as np
from numpy.polynomial import hermite_e 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_e polynomial and x, y, z sample points, use the hermite_e.hermevander3d() in Python Numpy
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",H.hermevander3d(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.70900000e+01 1.32977000e+02
6.23508100e+02 3.70000000e+00 1.96100000e+01 1.00233000e+02
4.92014900e+02 2.30697997e+03 1.26900000e+01 6.72570000e+01
3.43772100e+02 1.68747813e+03 7.91231779e+03 3.95530000e+01
2.09630900e+02 1.07149077e+03 5.25963928e+03 2.46616159e+04
1.50000000e+00 7.95000000e+00 4.06350000e+01 1.99465500e+02
9.35262150e+02 5.55000000e+00 2.94150000e+01 1.50349500e+02
7.38022350e+02 3.46046996e+03 1.90350000e+01 1.00885500e+02
5.15658150e+02 2.53121720e+03 1.18684767e+04 5.93295000e+01
3.14446350e+02 1.60723616e+03 7.88945892e+03 3.69924238e+04
1.25000000e+00 6.62500000e+00 3.38625000e+01 1.66221250e+02
7.79385125e+02 4.62500000e+00 2.45125000e+01 1.25291250e+02
6.15018625e+02 2.88372496e+03 1.58625000e+01 8.40712500e+01
4.29715125e+02 2.10934766e+03 9.89039724e+03 4.94412500e+01
2.62038625e+02 1.33936346e+03 6.57454910e+03 3.08270198e+04]
[1.00000000e+00 6.60000000e+00 4.25600000e+01 2.67696000e+02
1.63911360e+03 4.40000000e+00 2.90400000e+01 1.87264000e+02
1.17786240e+03 7.21209984e+03 1.83600000e+01 1.21176000e+02
7.81401600e+02 4.91489856e+03 3.00941257e+04 7.19840000e+01
4.75094400e+02 3.06363904e+03 1.92698289e+04 1.17989953e+05
2.30000000e+00 1.51800000e+01 9.78880000e+01 6.15700800e+02
3.76996128e+03 1.01200000e+01 6.67920000e+01 4.30707200e+02
2.70908352e+03 1.65878296e+04 4.22280000e+01 2.78704800e+02
1.79722368e+03 1.13042667e+04 6.92164891e+04 1.65563200e+02
1.09271712e+03 7.04636979e+03 4.43206064e+04 2.71376893e+05
4.29000000e+00 2.83140000e+01 1.82582400e+02 1.14841584e+03
7.03179734e+03 1.88760000e+01 1.24581600e+02 8.03362560e+02
5.05302970e+03 3.09399083e+04 7.87644000e+01 5.19845040e+02
3.35221286e+03 2.10849148e+04 1.29103799e+05 3.08811360e+02
2.03815498e+03 1.31430115e+04 8.26675658e+04 5.06176900e+05]]