ในการสร้างเมทริกซ์ Vandermonde ของพหุนาม Chebyshev ให้ใช้ chebyshev.chebvander() ใน Python Numpy วิธีการส่งคืนเมทริกซ์ Vandermonde รูปร่างของเมทริกซ์ที่ส่งคืน isx.shape + (deg + 1,) โดยที่ดัชนีสุดท้ายคือระดับของพหุนาม Chebyshev ที่สอดคล้องกัน dtype จะเหมือนกับค่า x ที่แปลงแล้ว
พารามิเตอร์ a คืออาร์เรย์ของจุด dtype ถูกแปลงเป็น float64 หรือ complex128 ขึ้นอยู่กับว่าองค์ประกอบใดที่ซับซ้อน ถ้า x เป็นสเกลาร์ จะถูกแปลงเป็นอาร์เรย์ 1 มิติ พารามิเตอร์ deg คือระดับของเมทริกซ์ผลลัพธ์
ขั้นตอน
ขั้นแรก นำเข้าไลบรารีที่จำเป็น -
import numpy as np from numpy.polynomial import chebyshev as C
สร้างอาร์เรย์ -
x = np.array([0, 1, -1, 2])
แสดงอาร์เรย์ -
print("Our Array...\n",x) ตรวจสอบขนาด -
print("\nDimensions of our Array...\n",x.ndim) รับประเภทข้อมูล -
print("\nDatatype of our Array object...\n",x.dtype) รับรูปร่าง -
print("\nShape of our Array object...\n",x.shape) ในการสร้างเมทริกซ์ Vandermonde ของพหุนาม Chebyshev ให้ใช้ chebyshev.chebvander() ใน Python -
print("\nResult...\n",C.chebvander(x, 2)) ตัวอย่าง
import numpy as np
from numpy.polynomial import chebyshev as C
# Create an array
x = np.array([0, 1, -1, 2])
# Display the array
print("Our Array...\n",x)
# Check the Dimensions
print("\nDimensions of our Array...\n",x.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",x.dtype)
# Get the Shape
print("\nShape of our Array object...\n",x.shape)
# To generate a Vandermonde matrix of the Chebyshev polynomial, use the chebyshev.chebvander() in Python Numpy
print("\nResult...\n",C.chebvander(x, 2)) ผลลัพธ์
Our Array... [ 0 1 -1 2] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (4,) Result... [[ 1. 0. -1.] [ 1. 1. 1.] [ 1. -1. 1.] [ 1. 2. 7.]]