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

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

บทนำ

เมธอด chebyshev.chebgrid3d() ประเมินอนุกรม Chebyshev 3 มิติ ที่ผลคูณการ์ทีเซียน (Cartesian product) ของ x, y และ z โดยใช้สัมประสิทธิ์ 2 มิติ

รายละเอียดพารามิเตอร์

  • x, y, z: จุดที่ประเมินในผลคูณการ์ทีเซียน แปลงเป็น ndarray หากเป็นลิสต์/ทูเพิล
  • c: อาร์เรย์สัมประสิทธิ์ c[i,j] สำหรับดีกรี i,j หาก c มีมิติ > 2 ดัชนีที่เหลือเป็นชุดสัมประสิทธิ์หลายชุด

หาก c มีมิติน้อยกว่า 3 จะเพิ่มมิติ 1 โดยอัตโนมัติ รูปร่างผลลัพธ์ = c.shape[3:] + x.shape + y.shape + z.shape

ขั้นตอนและตัวอย่าง

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

# สร้างอาร์เรย์สัมประสิทธิ์ 2 มิติ
c = np.arange(4).reshape(2, 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)

# ประเมินที่ Cartesian product ของ [1,2] สำหรับ x, y, z
print("\nResult...\n", C.chebgrid3d([1, 2], [1, 2], [1, 2], c))

ผลลัพธ์

Our Array... [[0 1]
 [2 3]]
Dimensions of our Array... 2
Datatype of our Array object... int64
Shape of our Array object... (2, 2)
Result... [[17. 28.]
 [28. 46.]]