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

ประเมินอนุกรม Chebyshev 2 มิติ ที่ Cartesian product x,y สัมประสิทธิ์ 1D ใน Python

บทนำ

เมธอด chebyshev.chebgrid2d() ประเมินอนุกรม Chebyshev 2 มิติ ที่ผลคูณการ์ทีเซียนของ x และ y

พารามิเตอร์

  • x, y: จุดใน Cartesian product แปลงเป็น ndarray อัตโนมัติ
  • c: สัมประสิทธิ์ c[i,j] สำหรับมัลติดีกรี i,j หาก c มีมิติ < 2 จะเพิ่มมิติ 1 อัตโนมัติ

ตัวอย่าง: สัมประสิทธิ์ 1 มิติ

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

c = np.array([3, 5])
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.chebgrid2d([1, 2], [1, 2], c))

ผลลัพธ์

Our Array... [3 5]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (2,)
Result... [21. 34.]

อาร์เรย์ 1D [3,5] ถูกขยายเป็น 2D อัตโนมัติ ผลลัพธ์เป็นเวกเตอร์ 2 องค์ประกอบจาก Cartesian product ของ [1,2] × [1,2]