在Python中用三维数组的系数评估点(x, y)的二维切比雪夫级数
在这篇文章中,我们将讨论如何在Python中评估在点(x, y)的二维切比雪夫级数与三维数组的系数。
输入:
[[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]]
[[ 9 10 11]
[12 13 14]
[15 16 17]]
[[18 19 20]
[21 22 23]
[24 25 26]]]
输出:
[[[1920. 522.]
[ 414. 108.]]
[[2020. 552.]
[ 444. 117.]]
[[2120. 582.]
[ 474. 126.]]]
解释:二维切比雪夫数列。
NumPy.polynomial.Chebyshev.chebgrid2d 方法
为了进行切比雪夫微分,NumPy提供了一个名为Chebyshev.chebgrid2d的函数,可以用来评估二维切比雪夫数列的笛卡尔积。这个函数只有在参数x和y是图元或列表且形状相同的情况下才会将其转换为数组,否则就不做任何改变,如果不是数组,则被当作标量处理。如果c的维数大于2,则其余的指数列举出多组系数。
语法: chebyshev.chebgrid2d(x,y, c)
参数:
- x,y。输入数组。
- c:系数数组的排序
返回:二维切比雪夫级数在x和y的笛卡尔乘积中的点。
示例 1:
在第一个例子中,让我们考虑一个大小为27的三维数组c和一系列的[2,2],[2,2]来对二维数组进行评估。
import numpy as np
from numpy.polynomial import chebyshev
# co.efficient array
c = np.arange(27).reshape(3, 3, 3)
print(f'The co.efficient array is {c}')
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
# evaluating co.eff array with a chebyshev series
res = chebyshev.chebgrid2d([2, 2], [2, 2], c)
# resultant array
print(f'Resultant series ---> {res}')
输出:
The co.efficient array is [[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]]
[[ 9 10 11]
[12 13 14]
[15 16 17]]
[[18 19 20]
[21 22 23]
[24 25 26]]]
The shape of the array is (3, 3, 3)
The dimension of the array is 3D
The datatype of the array is int32
Resultant series ---> [[[1920. 1920.]
[1920. 1920.]]
[[2020. 2020.]
[2020. 2020.]]
[[2120. 2120.]
[2120. 2120.]]]
示例 2:
在第一个例子中,让我们考虑一个大小为27的三维数组c和一系列的[2,1],[2,1],来对二维数组进行评估。
import numpy as np
from numpy.polynomial import chebyshev
# co.efficient array
c = np.arange(27).reshape(3, 3, 3)
print(f'The co.efficient array is {c}')
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
# evaluating co.eff array with a chebyshev series
res = chebyshev.chebgrid2d([2, 1], [2, 1], c)
# resultant array
print(f'Resultant series ---> {res}')
输出:
The co.efficient array is [[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]]
[[ 9 10 11]
[12 13 14]
[15 16 17]]
[[18 19 20]
[21 22 23]
[24 25 26]]]
The shape of the array is (3, 3, 3)
The dimension of the array is 3D
The datatype of the array is int32
Resultant series ---> [[[1920. 522.]
[ 414. 108.]]
[[2020. 552.]
[ 444. 117.]]
[[2120. 582.]
[ 474. 126.]]]