ในการส่งคืนเมทริกซ์ที่แสดงร่วมที่ปรับขนาดของอาร์เรย์ 1-D ของสัมประสิทธิ์พหุนาม ให้ส่งคืนเมธอด thehermite.hermcompanion() ใน Python Numpy พหุนามพื้นฐานถูกปรับขนาดเพื่อให้เมทริกซ์คู่หูสมมาตรเมื่อ c เป็นพหุนามฐานเฮอร์ไมต์ สิ่งนี้ให้ค่าประมาณค่าลักษณะเฉพาะที่ดีกว่ากรณีที่ไม่ได้มาตราส่วน และสำหรับพหุนามพื้นฐาน ค่าลักษณะเฉพาะรับประกันว่าเป็นจริง ถ้า numpy.linalg.eigvalsh ถูกใช้เพื่อให้ได้มา เมธอดส่งคืนเมทริกซ์ Scaledcompanion ของมิติ (deg, deg) พารามิเตอร์ c คืออาร์เรย์ 1-D ของอนุกรมเฮอร์ไมต์สัมประสิทธิ์ที่เรียงลำดับจากระดับต่ำไปสูง
ขั้นตอน
ขั้นแรก นำเข้าไลบรารีที่จำเป็น -
import numpy as np from numpy.polynomial import hermite as H
สร้างอาร์เรย์ 1D ของสัมประสิทธิ์ -
c = np.array([1, 2, 3])
แสดงอาร์เรย์ -
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)
ในการส่งคืนเมทริกซ์สหายที่ปรับขนาดของอาร์เรย์ 1-D ของสัมประสิทธิ์พหุนาม ให้ส่งคืนเมธอด thehermite.hermcompanion() ใน Python Numpy -
print("\nResult...\n",H.hermcompanion(c)) ตัวอย่าง
import numpy as np
from numpy.polynomial import hermite as H
# Create a 1D array of coefficients
c = np.array([1, 2, 3])
# 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 return the scaled companion matrix of a 1-D array of polynomial coefficients, return the hermite.hermcompanion() method in Python Numpy
print("\nResult...\n",H.hermcompanion(c)) ผลลัพธ์
Our Array... [1 2 3] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (3,) Result... [[ 0. 0.58925565] [ 0.70710678 -0.33333333]]