Để tạo ma trận Vandermonde giả của đa thức Hermite_e và các điểm mẫu x, y, z, sử dụng phương thức hermite_e.hermevander3d() trong NumPy Python. Phương thức trả về ma trận Vandermonde giả. Các tham số x, y, z là mảng tọa độ điểm, tất cả có cùng hình dạng. Kiểu dữ liệu sẽ được chuyển đổi sang float64 hoặc complex128 tùy thuộc vào việc các phần tử có phức hay không. Các giá trị vô hướng được chuyển đổi thành mảng 1 chiều. Tham số deg là danh sách các bậc tối đa dạng [x_deg, y_deg, z_deg].
Các bước thực hiện
Trước tiên, nhập thư viện cần thiết:
import numpy as np
from numpy.polynomial import hermite_e as H
Tạo mảng tọa độ điểm, tất cả cùng hình dạng bằng numpy.array():
x = np.array([-2.+2.j, -1.+2.j])
y = np.array([0.+2.j, 1.+2.j])
z = np.array([2.+2.j, 3. + 3.j])
Hiển thị các mảng:
print("Array1...\n", x)
print("\nArray2...\n", y)
print("\nArray3...\n", z)
Hiển thị kiểu dữ liệu:
print("\nArray1 datatype...\n", x.dtype)
print("\nArray2 datatype...\n", y.dtype)
print("\nArray3 datatype...\n", z.dtype)
Kiểm tra số chiều:
print("\nDimensions of Array1...\n", x.ndim)
print("\nDimensions of Array2...\n", y.ndim)
print("\nDimensions of Array3...\n", z.ndim)
Kiểm tra hình dạng:
print("\nShape of Array1...\n", x.shape)
print("\nShape of Array2...\n", y.shape)
print("\nShape of Array3...\n", z.shape)
Tạo ma trận Vandermonde giả của đa thức Hermite_e:
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n", H.hermevander3d(x, y, z, [x_deg, y_deg, z_deg]))
Ví dụ hoàn chỉnh
import numpy as np
from numpy.polynomial import hermite_e as H
x = np.array([-2.+2.j, -1.+2.j])
y = np.array([0.+2.j, 1.+2.j])
z = np.array([2.+2.j, 3. + 3.j])
print("Array1...\n", x)
print("\nArray2...\n", y)
print("\nArray3...\n", z)
print("\nArray1 datatype...\n", x.dtype)
print("\nArray2 datatype...\n", y.dtype)
print("\nArray3 datatype...\n", z.dtype)
print("\nDimensions of Array1...\n", x.ndim)
print("\nDimensions of Array2...\n", y.ndim)
print("\nDimensions of Array3...\n", z.ndim)
print("\nShape of Array1...\n", x.shape)
print("\nShape of Array2...\n", y.shape)
print("\nShape of Array3...\n", z.shape)
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n", H.hermevander3d(x, y, z, [x_deg, y_deg, z_deg]))
Kết quả đầu ra
Array1... [-2.+2.j -1.+2.j]
Array2... [0.+2.j 1.+2.j]
Array3... [2.+2.j 3.+3.j]
Array1 datatype... complex128
Array2 datatype... complex128
Array3 datatype... complex128
Dimensions of Array1... 1
Dimensions of Array2... 1
Dimensions of Array3... 1
Shape of Array1... (2,)
Shape of Array2... (2,)
Shape of Array3... (2,)
Result... [[ 1.0000e+00+0.000e+00j 2.0000e+00+2.000e+00j -1.0000e+00+8.000e+00j ... ]]