要在 x、y、z 的笛卡尔积上评估 3-D Chebyshev 级数,请使用d(x, y, z)Python 中的 polynomial.chebgrid3 方法。如果 c 的维度少于三个,则将隐式附加到其形状以使其成为 3-D。结果的形状将是 c.shape[3:] + x.shape+ y.shape+ z.shape。
参数 x、y 和 z 是在 x、y 和 z 的笛卡尔积中的点处评估的三维序列。如果 x、`y` 或 z 是列表或元组,则首先将其转换为 ndarray,否则保持不变,如果不是 ndarray,则将其视为标量。
参数 c 是一个已排序的系数数组,以便 i,j 次项的系数包含在 c[i,j] 中。如果 c 的维度大于两个,则其余索引会枚举多组系数。
脚步
首先,导入所需的库 -
import numpy as np fromnumpy.polynomialimport chebyshev as C
创建一个 3D 系数数组 -
c = np.arange(16).reshape(2,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、y、z 的笛卡尔积上的 3-D Chebyshev 系列,请使用 polynomial.chebgrid3d(x, y, z)方法 -
print("\nResult...\n",C.chebgrid3d([1,2],[1,2],[1,2], c))
示例
import numpy as np fromnumpy.polynomialimport chebyshev as C #创建一个 3D 系数数组 c = np.arange(16).reshape(2,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, y, z 的笛卡尔积上评估 3-D Chebyshev 系列,请使用 Python 中的 polynomial.chebgrid3d(x, y, z) 方法 print("\nResult...\n",C.chebgrid3d([1,2],[1,2],[1,2], c))输出结果
Our Array... [[[ 0 1 2 3] [ 4 5 6 7]] [[ 8 9 10 11] [12 13 14 15]]] Dimensions of our Array... 3 Datatype of our Array object... int64 Shape of our Array object... (2, 2, 4) Result... [[[ 120. 1240.] [ 196. 2004.]] [[ 212. 2148.] [ 342. 3438.]]]