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

ประเมินอนุกรม Hermite_e ที่ทูเพิลจุด x ใน Python

บทนำ

เมธอด hermite_e.hermeval() รองรับ x เป็นทูเพิล (tuple) แปลงเป็น ndarray อัตโนมัติเหมือนลิสต์

ตัวอย่าง: x เป็นทูเพิล (5, 10, 15)

import numpy as np
from numpy.polynomial import hermite_e as H

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)

x = (5, 10, 15)
print("\nResult...\n", H.hermeval(x, c))

ผลลัพธ์

Our Array... [1 2 3]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (3,)
Result... [ 83. 318. 703.]

ผลลัพธ์เหมือนกับการใช้ลิสต์ เพราะทั้งคู่ถูกแปลงเป็น ndarray เดียวกัน