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

ประเมินอนุกรม Chebyshev 3 มิติ ที่ Cartesian product x,y,z ใน Python

บทนำ

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

รายละเอียด

  • หาก c มีมิติ < 3 จะเพิ่มมิติ 1 อัตโนมัติ
  • รูปร่างผลลัพธ์ = c.shape[3:] + x.shape + y.shape + z.shape
  • x, y, z แปลงเป็น ndarray หากเป็นลิสต์/ทูเพิล

ตัวอย่าง: สัมประสิทธิ์ 3 มิติ (2,2,4)

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

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

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]]]
Dimensions of our Array... 3
Datatype of our Array object... int64
Shape of our Array object... (2, 2, 4)
Result... [[[ 120. 1240.]
   [ 196. 2004.]]
  [[ 212. 2148.]
   [ 342. 3438.]]]