เพื่อสร้างชุด Hermite_e จากรากซ้อนที่กำหนด ให้ใช้เมธอด hermite_e.hermefromroots() ใน Python Numpy เมธอดคืนค่าอาร์เรย์ 1-D ของ係 หากรากทั้งหมดเป็นจริง out จะเป็น real array หากบางรากเป็น complex out จะเป็น complex แม้係ทั้งหมดในผลลัพธ์จะเป็นจริง พารามิเตอร์ roots คือลำดับที่มีราก
ขั้นตอน
ก่อนอื่น import ไลบรารีที่จำเป็น:
from numpy.polynomial import hermite_e as H
สร้างชุด Hermite_e จากรากซ้อน:
j = complex(0,1)
print("Result...\n", H.hermefromroots((-j, j)))
ดึง datatype:
print("\nType...\n", H.hermefromroots((-j, j)).dtype)
ดึง shape:
print("\nShape...\n", H.hermefromroots((-j, j)).shape)
ตัวอย่าง
from numpy.polynomial import hermite_e as H
j = complex(0,1)
print("Result...\n", H.hermefromroots((-j, j)))
# Get the datatype
print("\nType...\n", H.hermefromroots((-j, j)).dtype)
# Get the shape
print("\nShape...\n", H.hermefromroots((-j, j)).shape)
ผลลัพธ์
Result... [2.+0.j 0.+0.j 1.+0.j] Type... complex128 Shape... (3,)