std::assoc_legendre, std::assoc_legendref, std::assoc_legendrel
| ヘッダー <cmath> で定義 |
||
| (1) | ||
float assoc_legendre ( unsigned int n, unsigned int m, float x ); double assoc_legendre ( unsigned int n, unsigned int m, 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以降) |
std::assoc_legendre のオーバーロードを提供します。(since C++23)目次 |
[edit] パラメータ
| n | - | 多項式の次数、符号なし整数値 |
| m | - | 多項式の順序、符号なし整数値 |
| x | - | 引数、浮動小数点数または整数値 |
[edit] 戻り値
エラーが発生しなかった場合、Pmn であるルジャンドル陪多項式の x における値が返されます。これは (1-x2
)m/2
| dm |
| dxm |
なお、この定義からはコンドン・ショートレー位相因子 (-1)m
は除かれています。
[edit] エラー処理
math_errhandling で指定されているように、エラーが報告される場合があります。
- 引数が NaN の場合、NaN が返され、ドメインエラーは報告されません。
- もし |x| > 1 の場合、定義域エラーが発生する可能性があります。
- もし
nが 128 以上の場合、動作は実装定義です。
[edit] 注記
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 の定義はコンドン・ショートレー位相因子を含んでいます。
最初のいくつかのルジャンドル陪多項式は次のとおりです。
| Function | 多項式 | ||
|---|---|---|---|
| assoc_legendre(0, 0, x) | 1 | ||
| assoc_legendre(1, 0, x) | x | ||
| assoc_legendre(1, 1, x) | (1 - x2 )1/2 | ||
| assoc_legendre(2, 0, x) |
- 1) | ||
| assoc_legendre(2, 1, x) | 3x(1 - x2 )1/2 | ||
| assoc_legendre(2, 2, x) | 3(1 - x2 ) |
追加のオーバーロードは、(A) とまったく同じように提供する必要はありません。整数型の引数 num に対して、 std::assoc_legendre(int_num1, int_num2, num) が std::assoc_legendre(int_num1, int_num2, static_cast<double>(num)) と同等の効果を持つことを保証するのに十分であればよいとされています。
[edit] 例
#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() { // spot-checks 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
[edit] 関連項目
| (C++17)(C++17)(C++17) |
ルジャンドル多項式 (関数) |
[edit] 外部リンク
| Weisstein, Eric W. "Associated Legendre Polynomial." From MathWorld — A Wolfram Web Resource. |