std:: legendre, std:: legendref, std:: legendrel
|
ヘッダー
<cmath>
で定義
|
||
| (1) | ||
|
float
legendre
(
unsigned
int
n,
float
x
)
;
double
legendre
(
unsigned
int
n,
double
x
)
;
|
(C++17以降)
(C++23以前) |
|
|
/* floating-point-type */
legendre
(
unsigned
int
n,
/* floating-point-type */ x ) ; |
(C++23以降) | |
|
float
legendref
(
unsigned
int
n,
float
x
)
;
|
(2) | (C++17以降) |
|
long
double
legendrel
(
unsigned
int
n,
long
double
x
)
;
|
(3) | (C++17以降) |
|
ヘッダー
<cmath>
で定義
|
||
|
template
<
class
Integer
>
double legendre ( unsigned int n, Integer x ) ; |
(A) | (C++17以降) |
std::legendre
のオーバーロードを提供する。
(C++23以降)
目次 |
パラメータ
| n | - | 多項式の次数 |
| x | - | 引数、浮動小数点または整数値 |
戻り値
If no errors occur, value of the order- n unassociated Legendre polynomial of x , that is| 1 |
|
2
n
n! |
|
d
n
|
|
dx
n
|
-1) n
, is returned.
エラー処理
エラーは、 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 でも利用可能です。
最初のいくつかのルジャンドル多項式は次のとおりです:
| 関数 | 多項式 | ||
|---|---|---|---|
| legendre ( 0 , x ) | 1 | ||
| legendre ( 1 , x ) | x | ||
| legendre ( 2 , x ) |
- 1) |
||
| legendre ( 3 , x ) |
- 3x) |
||
| legendre ( 4 , x ) |
- 30x 2 + 3) |
追加のオーバーロードは (A) と完全に同一である必要はありません。それらは、整数型の引数 num に対して、 std :: legendre ( int_num, num ) が std :: legendre ( int_num, static_cast < double > ( num ) ) と同じ効果を持つことを保証するのに十分であればよいのです。
例
#include <cmath> #include <iostream> double P3(double x) { return 0.5 * (5 * std::pow(x, 3) - 3 * x); } double P4(double x) { return 0.125 * (35 * std::pow(x, 4) - 30 * x * x + 3); } int main() { // スポットチェック std::cout << std::legendre(3, 0.25) << '=' << P3(0.25) << '\n' << std::legendre(4, 0.25) << '=' << P4(0.25) << '\n'; }
出力:
-0.335938=-0.335938 0.157715=0.157715
関連項目
|
(C++17)
(C++17)
(C++17)
|
ラゲール多項式
(関数) |
|
(C++17)
(C++17)
(C++17)
|
エルミート多項式
(関数) |
外部リンク
| Weisstein, Eric W. "Legendre Polynomial." MathWorld — Wolfram Web リソースより。 |