เพื่อประเมินพหุนาม 3 มิติ บนผลคูณการ์ทีเซียนของ x, y, z ให้ใช้ polynomial.polygrid3d(x, y, z, c) เมธอดนี้คืนค่าพหุนาม 3 มิติ ณ จุดในผลคูณการ์ทีเซียน
พารามิเตอร์
- x, y, z: จุดประเมิน 3 มิติ แปลงเป็น ndarray หากเป็นลิสต์/ทูเพิล มิฉะนั้นถือเป็นสเกลาร์
- c: อาร์เรย์係ส เรียงทำให้係สพจน์ i,j อยู่ใน
c[i,j]หากมิติ > 2 ดัชนีเหลือเป็นชุด係สหลายชุด หาก < 3 มิติ เพิ่มมิติ 1 อัตโนมัติ รูปทรงผลลัพธ์:c.shape[3:] + x.shape + y.shape + z.shape
ตัวอย่างกับ係ส 4 มิติ
import numpy as np
from numpy.polynomial.polynomial import polygrid3d
# สร้างอาร์เรย์係ส 4 มิติ (2, 2, 6, 2)
c = np.arange(48).reshape(2, 2, 6, 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(48).reshape(2, 2, 6, 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] [ 4 5] [ 6 7] [ 8 9] [10 11]]
[[12 13] [14 15] [16 17] [18 19] [20 21] [22 23]]]
[[[24 25] [26 27] [28 29] [30 31] [32 33] [34 35]]
[[36 37] [38 39] [40 41] [42 43] [44 45] [46 47]]]]
มิติ...
4
ชนิดข้อมูล...
int64
รูปทรง...
(2, 2, 6, 2)
ผลลัพธ์...
[[[[ 552. 6600.] [ 900. 10656.]]
[[ 972. 11412.] [1566. 18252.]]]
[[[ 576. 6852.] [ 936. 11034.]]
[[1008. 11790.] [1620. 18819.]]]]