在 Python 中生成带有点坐标复数数组的 Hermite 多项式的伪 Vandermonde 矩阵
pythonnumpyserver side programmingprogramming更新于 2024/5/24 7:40:17
要生成 Hermite 多项式的伪 Vandermonde 矩阵,请使用 Python Numpy 中的 hermite.hermvander2d()。该方法返回伪 Vandermonde 矩阵。参数 x、y 是点坐标数组,所有点坐标的形状均相同。dtype 将转换为 float64 或 complex128,具体取决于是否有任何元素是复数。标量将转换为一维数组。参数 deg 是 [x_deg, y_deg] 形式的最大度数列表。
步骤
首先,导入所需的库 −
import numpy as np from numpy.polynomial import hermite as H
使用 numpy.array() 方法 − 创建点坐标数组,所有数组的形状相同
x = np.array([-2.+2.j, -1.+2.j]) y = np.array([1.+2.j, 2.+2.j])
显示数组 −
print("Array1...\n",x)
print("\nArray2...\n",y)
显示数据类型 −
print("\nArray1 datatype...\n",x.dtype)
print("\nArray2 datatype...\n",y.dtype)
检查两个数组的维度 −
print("\nDimensions of Array1...\n",x.ndim)
print("\nDimensions of Array2...\n",y.ndim)
检查两个数组的形状 −
print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
要生成 Hermite 多项式的伪 Vandermonde 矩阵,请使用 Python Numpy 中的 hermite.hermvander2d()。该方法返回伪范德蒙矩阵 −
x_deg, y_deg = 2, 3
print("\n结果...\n",H.hermvander2d(x,y, [x_deg, y_deg]))
示例
import numpy as np
from numpy.polynomial import hermite as H
# 使用 numpy.array() 方法创建点坐标数组,所有数组的形状相同
x = np.array([-2.+2.j, -1.+2.j])
y = np.array([1.+2.j, 2.+2.j])
# 显示数组
print("Array1...\n",x)
print("\nArray2...\n",y)
# 显示数据类型
print("\nArray1 datatype...\n",x.dtype)
print("\nArray2 datatype...\n",y.dtype)
# 检查两个数组的维度
print("\nDimensions of Array1...\n",x.ndim)
print("\nDimensions of Array2...\n",y.ndim)
# 检查两个数组的形状
print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
# 要生成 Hermite 多项式的伪 Vandermonde 矩阵,请使用Python Numpy 中的 hermite.hermvander2d()
# 该方法返回伪范德蒙矩阵。
x_deg, y_deg = 2, 3
print("\n结果...\n",H.hermvander2d(x,y, [x_deg, y_deg]))
输出
Array1... [-2.+2.j -1.+2.j] Array2... [1.+2.j 2.+2.j] Array1 datatype... complex128 Array2 datatype... complex128 Dimensions of Array1... 1 Dimensions of Array2... 1 Shape of Array1... (2,) Shape of Array2... (2,) 结果... [[ 1.000e+00 +0.j 2.000e+00 +4.j -1.400e+01 +16.j -1.000e+02 -40.j -4.000e+00 +4.j -2.400e+01 -8.j -8.000e+00 -120.j 5.600e+02 -240.j -2.000e+00 -32.j 1.240e+02 -72.j 5.400e+02 +416.j -1.080e+03 +3280.j] [ 1.000e+00 +0.j 4.000e+00 +4.j -2.000e+00 +32.j -1.520e+02 +104.j -2.000e+00 +4.j -2.400e+01 +8.j -1.240e+02 -72.j -1.120e+02 -816.j -1.400e+01 -16.j 8.000e+00 -120.j 5.400e+02 -416.j 3.792e+03 +976.j]]
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

