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

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]の形式の最大度のリストです。

ステップ

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

import numpy as np
from numpy.polynomial import chebyshev as C

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

x = np.array([1.5, 2.3])
y = np.array([3.7, 4.4])
z = np.array([5.3, 6.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サンプル点の疑似ファンデルモンド行列を生成するには、chebyshev.chebvander()-

を使用します。
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",C.chebvander3d(x,y, z, [x_deg, y_deg, z_deg]))

import numpy as np
from numpy.polynomial import chebyshev as C

# Create arrays of point coordinates, all of the same shape using the numpy.array() method
x = np.array([1.5, 2.3])
y = np.array([3.7, 4.4])
z = np.array([5.3, 6.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 Chebyshev polynomial and x, y, z sample points, use the chebyshev.chebvander() in Python Numpy
x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",C.chebvander3d(x,y, z, [x_deg, y_deg, z_deg]))

出力

Array1...
[1.5 2.3]

Array2...
[3.7 4.4]

Array3...
[5.3 6.6]

Array1 datatype...
float64

Array2 datatype...
float64

Array3 datatype...
float64

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.30000000e+00 5.51800000e+01 5.79608000e+02
6.08866480e+03 3.70000000e+00 1.96100000e+01 2.04166000e+02
2.14454960e+03 2.25280598e+04 2.63800000e+01 1.39814000e+02
1.45564840e+03 1.52900590e+04 1.60618977e+05 1.91512000e+02
1.01501360e+03 1.05676322e+04 1.11001887e+05 1.16605237e+06
1.50000000e+00 7.95000000e+00 8.27700000e+01 8.69412000e+02
9.13299720e+03 5.55000000e+00 2.94150000e+01 3.06249000e+02
3.21682440e+03 3.37920896e+04 3.95700000e+01 2.09721000e+02
2.18347260e+03 2.29350886e+04 2.40928466e+05 2.87268000e+02
1.52252040e+03 1.58514482e+04 1.66502831e+05 1.74907856e+06
3.50000000e+00 1.85500000e+01 1.93130000e+02 2.02862800e+03
2.13103268e+04 1.29500000e+01 6.86350000e+01 7.14581000e+02
7.50592360e+03 7.88482092e+04 9.23300000e+01 4.89349000e+02
5.09476940e+03 5.35152066e+04 5.62166421e+05 6.70292000e+02
3.55254760e+03 3.69867126e+04 3.88506606e+05 4.08118331e+06]
[1.00000000e+00 6.60000000e+00 8.61200000e+01 1.13018400e+03
1.48323088e+04 4.40000000e+00 2.90400000e+01 3.78928000e+02
4.97280960e+03 6.52621587e+04 3.77200000e+01 2.48952000e+02
3.24844640e+03 4.26305405e+04 5.59474688e+05 3.27536000e+02
2.16173760e+03 2.82074003e+04 3.70175947e+05 4.85811510e+06
2.30000000e+00 1.51800000e+01 1.98076000e+02 2.59942320e+03
3.41143102e+04 1.01200000e+01 6.67920000e+01 8.71534400e+02
1.14374621e+04 1.50102965e+05 8.67560000e+01 5.72589600e+02
7.47142672e+03 9.80502431e+04 1.28679178e+06 7.53332800e+02
4.97199648e+03 6.48770207e+04 8.51404677e+05 1.11736647e+07
9.58000000e+00 6.32280000e+01 8.25029600e+02 1.08271627e+04
1.42093518e+05 4.21520000e+01 2.78203200e+02 3.63013024e+03
4.76395160e+04 6.25211481e+05 3.61357600e+02 2.38496016e+03
3.11201165e+04 4.08400578e+05 5.35976751e+06 3.13779488e+03
2.07094462e+04 2.70226895e+05 3.54628557e+06 4.65407426e+07]]

  1. Pythonでチェビシェフ多項式の疑似ファンデルモンド行列を生成します

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

  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