Python
 Computer >> コンピューター >  >> プログラミング >> Python

Pythonでルジャンドル多項式と点のx、y、z配列の疑似ファンデルモンド行列を生成します


x、y、zサンプルポイントを持つルジャンドル多項式の疑似ファンデルモンド行列を生成するには、Python Numpyのlegendre.legvander3d()メソッドを使用します。度度とサンプルポイント(x、y、z)の疑似ファンデルモンド行列を返します。

パラメータx、y、zは、すべて同じ形状の点座標の配列です。 dtypeは、要素のいずれかが複合であるかどうかに応じて、float64またはcomplex128のいずれかに変換されます。スカラーは1-D配列に変換されます。パラメータdegは、[x_deg、y_deg、z_deg]の形式の最大度のリストです。

ステップ

まず、必要なライブラリをインポートします-

import numpy as np
from numpy.polynomial import legendre as L

numpy.array()メソッドを使用して、すべて同じ形状の点座標の配列を作成します-

x = np.array([1, 2])
y = np.array([3, 4])
z = np.array([5, 6])

配列を表示する-

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、y、zサンプルポイントを持つルジャンドル多項式の疑似ファンデルモンド行列を生成するには、Pythonでlegendre.legvander3d()メソッドを使用します-

x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",L.legvander3d(x,y,z, [x_deg, y_deg, z_deg]))

import numpy as np
from numpy.polynomial import legendre as L

# Create arrays of point coordinates, all of the same shape using the numpy.array() method
x = np.array([1, 2])
y = np.array([3, 4])
z = np.array([5, 6])

# Display the arrays
print("Array1...\n",x)
print("\nArray2...\n",y)
print("\nArray3...\n",z)

# Display the datatype
print("\nArray1 datatype...\n",x.dtype)
print("\nArray2 datatype...\n",y.dtype)
print("\nArray3 datatype...\n",z.dtype)

# Check the Dimensions of both the arrays
print("\nDimensions of Array1...\n",x.ndim)
print("\nDimensions of Array2...\n",y.ndim)
print("\nDimensions of Array3...\n",z.ndim)

# Check the Shape of both the arrays
print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
print("\nShape of Array3...\n",z.shape)

# To generate a pseudo Vandermonde matrix of the Legendre polynomial with x, y, z sample points, use the legendre.legvander3d() method in Python Numpy
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",L.legvander3d(x,y,z, [x_deg, y_deg, z_deg]))

出力

Array1...
   [1 2]

Array2...
   [3 4]

Array3...
   [5 6]

Array1 datatype...
int64

Array2 datatype...
int64

Array3 datatype...
int64

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.00000000e+00 5.00000000e+00 3.70000000e+01 3.05000000e+02
     2.64100000e+03 3.00000000e+00 1.50000000e+01 1.11000000e+02
     9.15000000e+02 7.92300000e+03 1.30000000e+01 6.50000000e+01
     4.81000000e+02 3.96500000e+03 3.43330000e+04 6.30000000e+01
     3.15000000e+02 2.33100000e+03 1.92150000e+04 1.66383000e+05
     1.00000000e+00 5.00000000e+00 3.70000000e+01 3.05000000e+02
     2.64100000e+03 3.00000000e+00 1.50000000e+01 1.11000000e+02
     9.15000000e+02 7.92300000e+03 1.30000000e+01 6.50000000e+01
     4.81000000e+02 3.96500000e+03 3.43330000e+04 6.30000000e+01
     3.15000000e+02 2.33100000e+03 1.92150000e+04 1.66383000e+05
     1.00000000e+00 5.00000000e+00 3.70000000e+01 3.05000000e+02
     2.64100000e+03 3.00000000e+00 1.50000000e+01 1.11000000e+02
     9.15000000e+02 7.92300000e+03 1.30000000e+01 6.50000000e+01
     4.81000000e+02 3.96500000e+03 3.43330000e+04 6.30000000e+01
     3.15000000e+02 2.33100000e+03 1.92150000e+04 1.66383000e+05]
    [1.00000000e+00 6.00000000e+00 5.35000000e+01 5.31000000e+02
     5.53537500e+03 4.00000000e+00 2.40000000e+01 2.14000000e+02
     2.12400000e+03 2.21415000e+04 2.35000000e+01 1.41000000e+02
     1.25725000e+03 1.24785000e+04 1.30081312e+05 1.54000000e+02
     9.24000000e+02 8.23900000e+03 8.17740000e+04 8.52447750e+05
     2.00000000e+00 1.20000000e+01 1.07000000e+02 1.06200000e+03
     1.10707500e+04 8.00000000e+00 4.80000000e+01 4.28000000e+02
     4.24800000e+03 4.42830000e+04 4.70000000e+01 2.82000000e+02
     2.51450000e+03 2.49570000e+04 2.60162625e+05 3.08000000e+02
     1.84800000e+03 1.64780000e+04 1.63548000e+05 1.70489550e+06
     5.50000000e+00 3.30000000e+01 2.94250000e+02 2.92050000e+03
     3.04445625e+04 2.20000000e+01 1.32000000e+02 1.17700000e+03
     1.16820000e+04 1.21778250e+05 1.29250000e+02 7.75500000e+02
     6.91487500e+03 6.86317500e+04 7.15447219e+05 8.47000000e+02
     5.08200000e+03 4.53145000e+04 4.49757000e+05 4.68846262e+06]]

  1. Pythonでチェビシェフ多項式と点のx、y、z浮動配列の疑似ファンデルモンド行列を生成します

    チェビシェフ多項式とx、y、zサンプルポイントの疑似ファンデルモンド行列を生成するには、Python Numpyでchebyshev.chebvander()を使用します。このメソッドは、度度とサンプルポイント(x、y、z)の疑似ファンデルモンド行列を返します。 パラメータx、y、zは、すべて同じ形状の点座標の配列です。 dtypeは、要素のいずれかが複合であるかどうかに応じて、float64またはcomplex128のいずれかに変換されます。スカラーは1-D配列に変換されます。パラメータdegは、[x_deg、y_deg、z_deg]の形式の最大度のリストです。 ステップ まず、必要な

  2. Pythonでエルミート多項式とx、y、z複素数の点の配列の疑似ファンデルモンド行列を生成します

    エルミート多項式とx、y、zサンプルポイントの疑似ファンデルモンド行列を生成するには、Python Numpyでhermite.hermvander3d()を使用します。このメソッドは、疑似ファンデルモンド行列を返します。パラメータx、y、zは、すべて同じ形状の点座標の配列です。 dtypeは、要素のいずれかが複雑であるかどうかに応じて、float64またはcomplex128のいずれかに変換されます。スカラーは1-D配列に変換されます。パラメータdegは、[x_deg、y_deg、z_deg]の形式の最大度のリストです。 ステップ まず、必要なライブラリをインポートします- numpy a