在 Python 中评估 Hermite_e 系列在点 x 处的值,并扩展每个 x 维度的系数数组的形状
要评估点 x 处的 Hermite_e 系列,请在 Python Numpy 中使用 hermite.hermeval() 方法。第一个参数 x,如果 x 是列表或元组,则将其转换为 ndarray,否则保持不变并将其视为标量。无论哪种情况,x 或其元素都必须支持自身以及 c 的元素之间的加法和乘法。
第二个参数 C,一个系数数组,其顺序使得 n 次项的系数包含在 c[n] 中。如果 c 是多维的,则其余索引枚举多个多项式。在二维情况下,可以认为系数存储在 c 的列中。
第三个参数 tensor,如果为 True,则系数数组的形状将在右侧扩展为 1,每个 x 维度一个。对于此操作,标量具有 0 维。结果是 c 中的每一列系数都针对 x 的每个元素进行评估。如果为 False,则在评估过程中将 x 广播到 c 的列上。当 c 是多维时,此关键字很有用。默认值为 True。
步骤
首先,导入所需的库 -
import numpy as np from numpy.polynomial import hermite_e as H
创建一个多维系数数组 -
c = np.arange(8).reshape(2,4)
显示数组 -
print("Our Array...\n",c)检查维度 -
print("\nDimensions of our Array...\n",c.ndim)获取数据类型 -
print("\nDatatype of our Array object...\n",c.dtype)获取形状 -
print("\nShape of our Array object...\n",c.shape)要评估点 x 处的 Hermite_e 系列,请在 Python Numpy 中使用 hermite.hermeval() 方法 -
print("\nResult...\n",H.hermeval([1,2],c, tensor = True))示例
import numpy as np
from numpy.polynomial import hermite_e as H
# Create a multidimensional array of coefficients
c = np.arange(8).reshape(2,4)
# Display the array
print("Our Array...\n",c)
# Check the Dimensions
print("\nDimensions of our Array...\n",c.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",c.dtype)
# Get the Shape
print("\nShape of our Array object...\n",c.shape)
# To evaluate a Hermite_e series at points x, use the hermite.hermeval() method in Python Numpy
print("\nResult...\n",H.hermeval([1,2],c, tensor = True))输出
Our Array... [[0 1 2 3] [4 5 6 7]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (2, 4) Result... [[ 4. 8.] [ 6. 11.] [ 8. 14.] [10. 17.]]
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP