ในการประเมินชุด Chebyshev แบบ 2 มิติที่จุด (x, y) ให้ใช้เมธอด polynomial.chebval2d() ในPython Numpy วิธีการคืนค่าชุด Chebyshev สองมิติที่จุดที่เกิดจากคู่ของค่าที่สอดคล้องกันจาก x และ y เช่น พารามิเตอร์ x, y อนุกรมสองมิติถูกประเมินที่จุด (x, y) โดยที่ x และ y ต้องมีรูปร่างเหมือนกัน หาก x หรือ y เป็นออร์ทูเปิลของรายการ จะถูกแปลงเป็น ndarray ก่อน มิฉะนั้น ค่าจะไม่เปลี่ยนแปลง และหากไม่ใช่ ndarray ค่าจะถูกนับเป็นสเกลาร์
พารามิเตอร์ c คืออาร์เรย์ของสัมประสิทธิ์ที่เรียงลำดับเพื่อให้สัมประสิทธิ์ของพจน์ของหลายองศา i,j อยู่ใน c[i,j] ถ้า c มีขนาดมากกว่า 2 ดัชนีที่เหลือจะแจกแจงค่าสัมประสิทธิ์หลายชุด
ขั้นตอน
ขั้นแรก นำเข้าไลบรารีที่จำเป็น -
import numpy as np from numpy.polynomial import chebyshev as C
สร้างอาร์เรย์หลายมิติของสัมประสิทธิ์ -
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) ในการประเมินอนุกรม 2 มิติ Chebyshev ที่จุด (x, y) ให้ใช้วิธี polynomial.chebval2d() -
print("\nResult...\n",C.chebval2d([1,2],[1,2], c)) ตัวอย่าง
import numpy as np
from numpy.polynomial import chebyshev as C
# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2,2)
# Display the array
print("Our Array...\n",c)
# Check the Dimensions
print("\nDimensions of our Array...\n",c.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",c.dtype)
# Get the Shape
print("\nShape of our Array object...\n",c.shape)
# To evaluate a 2-D Chebyshev series at points (x, y), use the polynomial.chebval2d() method in Python Numpy
print("\nResult...\n",C.chebval2d([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... [ 6. 18.]