Python Numpy np.polygrid2d()方法
np.polygrid2d() 方法用于评估x和y的笛卡尔乘积上的二维多项式序列。
语法: np.polygrid2d(x, y, c)
参数:
x, y : [array_like]二维数列在x和y的笛卡尔乘积中的各点进行评估。如果x或y是一个列表或元组,它首先被转换为ndarray,否则它将保持不变,如果它不是ndarray,它将被当作一个标量处理。
c : [array_like]数组的系数多项式数列。
返回 : [ndarray] 二维多项式数列在x和y的笛卡尔积中各点的值。
代码#1:
# Python program explaining
# numpy.polygrid2d() method
# importing numpy as np
import numpy as np
from numpy.polynomial.polynomial import polygrid2d
# Input polynomial series coefficients
c = np.array([[1, 3, 5], [2, 4, 6]])
# using np.polygrid2d() method
ans = polygrid2d([7, 9], [8, 10], c)
print(ans)
输出:
[[ 3271. 5025.]
[ 4107. 6309.]]
代码#2:
# Python program explaining
# numpy.polygrid2d() method
# importing numpy as np
import numpy as np
from numpy.polynomial.polynomial import polygrid2d
# Input polynomial series coefficients
c = np.array([[1, 3, 5], [2, 4, 6]])
# using np.polygrid2d() method
ans = polygrid2d(7, 8, c)
print(ans)
输出:
3271.0