Namespaces
Variants

std:: assoc_legendre, std:: assoc_legendref, std:: assoc_legendrel

From cppreference.net
헤더 파일에 정의됨 <cmath>
(1)
float assoc_legendre ( unsigned int n, unsigned int m, float x ) ;

double assoc_legendre ( unsigned int n, unsigned int m, double x ) ;

long double assoc_legendre ( unsigned int n, unsigned int m, long double x ) ;
(C++17부터)
(C++23까지)
/* floating-point-type */ assoc_legendre ( unsigned int n, unsigned int m,
/* floating-point-type */ x ) ;
(C++23부터)
float assoc_legendref ( unsigned int n, unsigned int m, float x ) ;
(2) (C++17부터)
long double assoc_legendrel ( unsigned int n, unsigned int m, long double x ) ;
(3) (C++17부터)
헤더 파일에 정의됨 <cmath>
template < class Integer >
double assoc_legendre ( unsigned int n, unsigned int m, Integer x ) ;
(A) (C++17부터)
1-3) 차수 n , 차 m , 및 인수 x 연관 르장드르 다항식 을 계산합니다. 라이브러리는 매개변수 x 의 타입으로 모든 cv-한정자 없는 부동소수점 타입에 대한 std::assoc_legendre 의 오버로드를 제공합니다. (C++23부터)
A) 모든 정수 타입에 대해 추가 오버로드가 제공되며, 이들은 double 로 처리됩니다.

목차

매개변수

n - 다항식의 차수, 부호 없는 정수 값
m - 다항식의 차, 부호 없는 정수 값
x - 인자, 부동 소수점 또는 정수 값

반환값

If no errors occur, value of the associated Legendre polynomial P m
n
of x , that is (1-x 2
) m/2
d m
dx m
P n (x)
, is returned (where P n (x) is the unassociated Legendre polynomial, std:: legendre ( n, x ) ).

참고로 Condon-Shortley 위상 항 (-1) m
이 이 정의에서 생략되었습니다.

오류 처리

오류는 다음과 같이 보고될 수 있습니다: math_errhandling

  • 인수가 NaN인 경우, NaN이 반환되고 도메인 오류가 보고되지 않음
  • 만약 |x| > 1 인 경우, 도메인 오류가 발생할 수 있음
  • 만약 n 이 128 이상인 경우, 동작은 구현에 따라 정의됨

참고 사항

C++17을 지원하지 않지만 ISO 29124:2010 을 지원하는 구현체는, 구현체가 __STDCPP_MATH_SPEC_FUNCS__ 를 최소 201003L 값으로 정의하고 사용자가 표준 라이브러리 헤더를 포함하기 전에 __STDCPP_WANT_MATH_SPEC_FUNCS__ 를 정의하는 경우 이 함수를 제공합니다.

ISO 29124:2010을 지원하지 않지만 TR 19768:2007(TR1)을 지원하는 구현에서는 이 함수를 tr1/cmath 헤더와 std::tr1 네임스페이스에서 제공합니다.

이 함수의 구현체는 또한 boost.math에서도 사용 가능합니다 , boost::math::legendre_p 로 제공되지만, boost.math 정의에는 Condon-Shortley 위상 항이 포함되어 있습니다.

처음 몇 개의 연관 르장드르 다항식은 다음과 같습니다:

함수 다항식
assoc_legendre ( 0 , 0 , x ) 1
assoc_legendre ( 1 , 0 , x ) x
assoc_legendre ( 1 , 1 , x ) (1 - x 2
) 1/2
assoc_legendre ( 2 , 0 , x )
1
2
(3x 2
- 1)
assoc_legendre ( 2 , 1 , x ) 3x(1 - x 2
) 1/2
assoc_legendre ( 2 , 2 , x ) 3(1 - x 2
)

추가 오버로드는 반드시 (A) 와 정확히 동일하게 제공될 필요는 없습니다. 정수 타입의 인수 num 에 대해 std :: assoc_legendre ( int_num1, int_num2, num ) std :: assoc_legendre ( int_num1, int_num2, static_cast < double > ( num ) ) 와 동일한 효과를 보장하기에 충분하기만 하면 됩니다.

예제

#include <cmath>
#include <iostream>
double P20(double x)
{
    return 0.5 * (3 * x * x - 1);
}
double P21(double x)
{
    return 3.0 * x * std::sqrt(1 - x * x);
}
double P22(double x)
{
    return 3 * (1 - x * x);
}
int main()
{
    // 간단 검증
    std::cout << std::assoc_legendre(2, 0, 0.5) << '=' << P20(0.5) << '\n'
              << std::assoc_legendre(2, 1, 0.5) << '=' << P21(0.5) << '\n'
              << std::assoc_legendre(2, 2, 0.5) << '=' << P22(0.5) << '\n';
}

출력:

-0.125=-0.125
1.29904=1.29904
2.25=2.25

참고 항목

(C++17) (C++17) (C++17)
르장드르 다항식
(함수)

외부 링크

Weisstein, Eric W. "Associated Legendre Polynomial." From MathWorld — A Wolfram Web Resource.