Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

ประเมินอนุกรม Chebyshev 3 มิติ ผลคูณการ์ทีเซียน x,y,z สัมประสิทธิ์ 4D ใน Python

บทนำ

เมธอด chebyshev.chebgrid3d() รองรับการประเมินอนุกรม Chebyshev 3 มิติ ด้วยอาร์เรย์สัมประสิทธิ์ 4 มิติ ผลลัพธ์จะมีมิติเพิ่มขึ้นตามชุดสัมประสิทธิ์ที่มีอยู่

ขั้นตอนการใช้งาน

1. นำเข้าและสร้างอาร์เรย์ 4 มิติ

import numpy as np
from numpy.polynomial import chebyshev as C

c = np.arange(48).reshape(2, 2, 6, 2)
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)

2. ประเมินที่ Cartesian product

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] [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]]]]
Dimensions of our Array... 4
Datatype of our Array object... int64
Shape of our Array object... (2, 2, 6, 2)
Result... [[[[ 552. 53976.] [ 900. 86904.]]
  [[ 972. 92844.] [1566. 148176.]]]
 [[[ 576. 55956.] [ 936. 89874.]]
  [[1008. 95814.] [1620. 152631.]]]]

อาร์เรย์ 4 มิติ (2,2,6,2) ให้ผลลัพธ์ 4 มิติ ตามสูตร c.shape[3:] + x.shape + y.shape + z.shape