เพื่อสร้างเมทริกซ์ Vandermonde ของพหุนาม Hermite_e ให้ใช้ hermite_e.hermevander() ใน Python Numpy เมธอดคืนค่า pseudo-Vandermonde matrix รูปร่างของเมทริกซ์ที่คืนคือ x.shape + (deg + 1,) โดยดัชนีสุดท้ายคืออันดับของพหุนาม Hermite_e ที่สอดคล้อง dtype จะเหมือนกับ x ที่แปลงแล้ว
พารามิเตอร์ x คืนค่าอาร์เรย์ของจุด dtype จะแปลงเป็น float64 หรือ complex128 ขึ้นอยู่กับว่ามีองค์ประกอบ complex หรือไม่ หาก x เป็น scalar จะแปลงเป็นอาร์เรย์ 1-D พารามิเตอร์ deg คืออันดับของเมทริกซ์ที่ได้
ขั้นตอน
ก่อนอื่น import ไลบรารีที่จำเป็น:
import numpy as np
from numpy.polynomial import hermite_e as H
สร้างอาร์เรย์:
x = np.array([0, 1, -1, 2])
แสดงอาร์เรย์:
print("Our Array...\n", x)
ตรวจสอบมิติ:
print("\nDimensions of our Array...\n", x.ndim)
ดึง datatype:
print("\nDatatype of our Array object...\n", x.dtype)
ดึง shape:
print("\nShape of our Array object...\n", x.shape)
สร้างเมทริกซ์ Vandermonde ด้วย hermite_e.hermevander():
print("\nResult...\n", H.hermevander(x, 2))
ตัวอย่าง
import numpy as np
from numpy.polynomial import hermite_e as H
# 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 Hermite_e polynomial
print("\nResult...\n", H.hermevander(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. 0.] [ 1. -1. 0.] [ 1. 2. 3.]]