Để đánh giá chuỗi Hermite_e 2-D trên tích Descartes của x và y, dùng phương thức hermite.hermegrid2d(x, y, c) trong Python. Phương thức trả về giá trị của đa thức 2 chiều tại các điểm trong tích Descartes của x và y.
Tham số là x, y. Đa thức 2 chiều được đánh giá tại các điểm trong tích Descartes của x và y. Nếu x hoặc y là list hoặc tuple, nó đầu tiên chuyển thành ndarray, ngược lại giữ nguyên và, nếu không phải ndarray, coi như scalar.
Tham số c là mảng hệ số có thứ tự sao cho hệ số cho terms degree i,j chứa trong c[i,j]. Nếu c có dimension lớn hơn 2, các index còn lại enumerate multiple sets của hệ số. Nếu c có ít hơn 2 dimension, 1 được ngầm thêm vào shape để làm nó 2-D. Shape của kết quả sẽ là c.shape[2:] + x.shape.
Các bước
Đầu tiên, import thư viện cần thiết:
import numpy as np from numpy.polynomial import hermite_e as H
Tạo mảng 3D hệ số:
c = np.arange(24).reshape(2,2,6)
Hiển thị mảng:
print("Our Array...\n", c)
Kiểm tra Dimensions:
print("\nDimensions of our Array...\n", c.ndim)
Lấy Datatype:
print("\nDatatype of our Array object...\n", c.dtype)
Lấy Shape:
print("\nShape of our Array object...\n", c.shape)
Đánh giá chuỗi Hermite_e 2-D trên tích Descartes của x và y, dùng hermite.hermegrid2d(x, y, c):
print("\nResult...\n", H.hermegrid2d([1,2],[1,2], c))
Ví dụ
import numpy as np
from numpy.polynomial import hermite_e as H
# Create a 3d array of coefficients
c = np.arange(24).reshape(2,2,6)
# 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 evaluate a 2-D Hermite_e series on the Cartesian product of x and y, use the hermite.hermegrid2d(x, y, c) method in Python
print("\nResult...\n", H.hermegrid2d([1,2],[1,2], c))
Kết quả
Our Array... [[[ 0 1 2 3 4 5] [ 6 7 8 9 10 11]] [[12 13 14 15 16 17] [18 19 20 21 22 23]]] Dimensions of our Array... 3 Datatype of our Array object... int64 Shape of our Array object... (2, 2, 6) Result... [[[ 36. 60.] [ 66. 108.]] [[ 40. 66.] [ 72. 117.]] [[ 44. 72.] [ 78. 126.]] [[ 48. 78.] [ 84. 135.]] [[ 52. 84.] [ 90. 144.]] [[ 56. 90.] [ 96. 153.]]]