Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Python에서 Hermite_e 시리즈 계수의 1차원 배열의 크기 조정된 컴패니언 행렬을 반환합니다.

<시간/>

다항식 계수의 1차원 배열의 크기 조정된 컴패니언 행렬을 반환하려면 Python Numpy에서 thehermite_e.hermecompanion() 메서드를 반환합니다. 기초 다항식은 c가 Hermite_e 기초 다항식일 때 컴패니언 행렬이 대칭이 되도록 스케일링됩니다. 이것은 스케일링되지 않은 경우보다 더 나은 고유값 추정치를 제공하고 기저 다항식의 경우 고유값을 얻기 위해 numpy.linalg.eigvalsh를 사용하면 고유값이 실수임을 보장합니다.

이 메서드는 차원(deg, deg)의 Scaled 동반 행렬을 반환합니다. 매개변수 c는 낮은 차수에서 높은 차수로 정렬된 Hermite 계열 계수의 1차원 배열입니다.

단계

먼저 필요한 라이브러리를 가져옵니다 -

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

계수의 1D 배열 생성 -

c = np.array([1, 2, 3])

배열 표시 -

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)

다항식 계수의 1차원 배열의 크기 조정된 컴패니언 행렬을 반환하려면 Python에서 thehermite_e.hermecompanion() 메서드를 반환합니다. -

print("\nResult...\n",H.hermecompanion(c))

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

# Create a 1D array of coefficients
c = np.array([1, 2, 3])

# 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 return the scaled companion matrix of a 1-D array of polynomial coefficients, return the hermite_e.hermecompanion() method in Python Numpy
print("\nResult...\n",H.hermecompanion(c))

출력

Our Array...
   [1 2 3]

Dimensions of our Array...
1

Datatype of our Array object...
int64

Shape of our Array object...
(3,)

Result...
   [[ 0. 0.66666667]
   [ 1. -0.66666667]]