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

ประเมินค่าอนุกรมเฮอร์ไมท์ 3 มิติ บนผลคูณคาร์เทเซียนของ x, y, z ด้วยอาร์เรย์係ณ 2 มิติใน Python

เมธอด hermite.hermgrid3d(x, y, z, c) ประเมินค่าอนุกรมเฮอร์ไมท์ 3 มิติ บนจุดในผลคูณคาร์เทเซียน (Cartesian product) ของ x, y, z

พารามิเตอร์ c เป็นอาร์เรย์係ณที่ c[i,j] เก็บ係ณของพจน์ดีกรี i,j หาก c มีมิติมากกว่า 2 ดัชนีที่เหลือจะแทนชุด係ณหลายชุด

ขั้นตอน

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

c = np.arange(4).reshape(2, 2)
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)
print("\nResult...\n", H.hermgrid3d([1, 2], [1, 2], [1, 2], c))

ตัวอย่างโค้ดสมบูรณ์

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

c = np.arange(4).reshape(2, 2)
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)
print("\nResult...\n", H.hermgrid3d([1, 2], [1, 2], [1, 2], c))

ผลลัพธ์

Our Array...   [[0 1] [2 3]]
Dimensions of our Array... 2
Datatype of our Array object... int64
Shape of our Array object... (2, 2)
Result...   [[ 86. 154.] [152. 272.]]