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

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

ตัวอย่างนี้ใช้ hermgrid3d กับอาร์เรย์係ณ 4 มิติ (shape (2, 2, 6, 2)) ซึ่งมิติที่ 3 และ 4 แทนชุด係ณหลายชุด

ขั้นตอน

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

c = np.arange(48).reshape(2, 2, 6, 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(48).reshape(2, 2, 6, 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))

ผลลัพธ์

ผลลัพธ์เป็นอาร์เรย์ 4 มิติที่มีค่าตัวเลขขนาดใหญ่ (ดูรายละเอียดในโค้ดต้นฉบับ)