เพื่อประเมินค่าพหุนาม 3 มิติ บนผลคูณการ์ทีเซียนของ x, y, z ให้ใช้เมธอด polynomial.polygrid3d(x, y, z, c) ใน Python เมธอดนี้คืนค่าของพหุนาม 3 มิติ ณ จุดในผลคูณการ์ทีเซียนของ x, y, z
พารามิเตอร์
- x, y, z: จุดประเมิน 3 มิติ แปลงเป็น ndarray หากเป็นลิสต์/ทูเพิล มิฉะนั้นถือเป็นสเกลาร์
- c: อาร์เรย์係ส เรียงทำให้係สพจน์ i,j อยู่ใน
c[i,j]หากมิติ > 2 ดัชนีเหลือเป็นชุด係สหลายชุด หาก < 3 มิติ จะเพิ่มมิติ 1 อัตโนมัติ รูปทรงผลลัพธ์:c.shape[3:] + x.shape + y.shape + z.shape
ขั้นตอนตัวอย่าง
import numpy as np
from numpy.polynomial.polynomial import polygrid3d
# สร้างอาร์เรย์係ส 2 มิติ
c = np.arange(4).reshape(2, 2)
# แสดงข้อมูล
print("อาร์เรย์ของเรา...\n", c)
print("\nมิติ...\n", c.ndim)
print("\nชนิดข้อมูล...\n", c.dtype)
print("\nรูปทรง...\n", c.shape)
# ประเมินพหุนาม 3 มิติ
print("\nผลลัพธ์...\n", polygrid3d([1, 2], [1, 2], [1, 2], c))
โค้ดเต็มและผลลัพธ์
import numpy as np
from numpy.polynomial.polynomial import polygrid3d
c = np.arange(4).reshape(2, 2)
print("อาร์เรย์ของเรา...\n", c)
print("\nมิติ...\n", c.ndim)
print("\nชนิดข้อมูล...\n", c.dtype)
print("\nรูปทรง...\n", c.shape)
print("\nผลลัพธ์...\n", polygrid3d([1, 2], [1, 2], [1, 2], c))
อาร์เรย์ของเรา...
[[0 1]
[2 3]]
มิติ...
2
ชนิดข้อมูล...
int64
รูปทรง...
(2, 2)
ผลลัพธ์...
[[17. 28.]
[28. 46.]]