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

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

ใช้ hermgrid3d กับอาร์เรย์係ณ 3 มิติ (shape (2, 2, 4)) ซึ่งมิติแรกและสองสอดคล้องกับดีกรี x,y และมิติที่สามสอดคล้องกับดีกรี z

ขั้นตอน

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

c = np.arange(16).reshape(2, 2, 4)
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(16).reshape(2, 2, 4)
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] [ 4 5 6 7]] [[ 8 9 10 11] [12 13 14 15]]]
Dimensions of our Array... 3
Datatype of our Array object... int64
Shape of our Array object... (2, 2, 4)
Result...   [[[ 18. 5616.] [ 38. 9832.]] [[ 46. 10304.] [ 90. 17960.]]]