Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

ส่งคืนเมทริกซ์สหายที่ปรับขนาดของอาร์เรย์ 1-D ของสัมประสิทธิ์พหุนาม Laguerre ใน Python


ในการส่งคืนเมทริกซ์ที่แสดงร่วมที่ปรับขนาดของอาร์เรย์ 1-D ของสัมประสิทธิ์พหุนาม Laguerre ให้ใช้ thelaguerre.lagvander3d() ใน Python Numpy เมทริกซ์ร่วมปกติของพหุนาม Laguerre มีความสมมาตรอยู่แล้วเมื่อ c เป็นพหุนามฐานของ Laguerre ดังนั้นจึงไม่มีการใช้มาตราส่วน

ส่งกลับเมทริกซ์ที่แสดงร่วมของมิติข้อมูล (deg, deg) พารามิเตอร์ c คืออาร์เรย์ 1-D ของสัมประสิทธิ์ Laguerreseries เรียงจากระดับต่ำไปสูง

ขั้นตอน

ขั้นแรก นำเข้าไลบรารีที่จำเป็น -

import numpy as np
from numpy.polynomial import laguerre as L

สร้างอาร์เรย์ 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 ของสัมประสิทธิ์พหุนาม Laguerre ให้ใช้ thelaguerre.lagvander3d() ใน Python Numpy -

print("\nResult...\n",L.lagcompanion(c))

ตัวอย่าง

import numpy as np
from numpy.polynomial import laguerre as L

# 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 Laguerre polynomial coefficients, use the laguerre.lagvander3d() in Python Numpy
print("\nResult...\n",L.lagcompanion(c))

ผลลัพธ์

Our Array...
   [1 2 3]

Dimensions of our Array...
1

Datatype of our Array object...
int64

Shape of our Array object...
(3,)

Result...
   [[ 1. -0.33333333]
   [-1. 4.33333333]]