要在 x、y 和 z 的笛卡尔积上评估 3D Legendre 系列,请使用d()Python Numpy 中的 polynomial.legendre.leggrid3 方法。该方法返回在 x 和 z 的笛卡尔积中的点处的三维切比雪夫级数的值。如果 c 的维度少于三个,则将隐式附加到其形状以使其成为 3-D。结果的形状将是 c.shape[3:] + x.shape+ y.shape+ z.shape。
第一个参数是 x、y、z。三维序列在 x、y 和 z 的笛卡尔积中的点进行评估。如果 x 或 y 是列表或元组,则首先将其转换为 ndarray,否则保持不变,如果不是 ndarray,则将其视为标量。
第二个参数是c。排序的系数数组,使得多度 i,j 项的系数包含在 c[i,j] 中。如果 c 的维度大于两个,则其余索引会枚举多组系数。
脚步
首先,导入所需的库 -
import numpy as np fromnumpy.polynomialimport legendre as L
创建一个二维系数数组 -
c = np.arange(4).reshape(2,2)
显示数组 -
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、y 和 z 的笛卡尔积上评估 3D Legendre 系列,请使用d()Python 中的 polynomial.legendre.leggrid3 方法 -
print("\nResult...\n",L.leggrid3d([1,2],[1,2],[1,2],c))
示例
import numpy as np fromnumpy.polynomialimport legendre as L #创建一个二维系数数组 c = np.arange(4).reshape(2,2) #显示数组 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、y 和 z 的笛卡尔积上评估 3D Legendre 系列,请使用 Python Numpy 中的 polynomial.legendre.leggrid3d() 方法 print("\nResult...\n",L.leggrid3d([1,2],[1,2],[1,2],c))输出结果
Our Array... [[0 1] [2 3]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (2, 2) Result... [[17. 28.] [28. 46.]]