名前空間
変種
操作

std::laguerre, std::laguerref, std::laguerrel

From cppreference.com
 
 
 
 
ヘッダー <cmath> で定義
(1)
float        laguerre ( unsigned int n, float x );

double      laguerre ( unsigned int n, double x );

long double laguerre ( unsigned int n, long double x );
(C++17以降)
(C++23まで)
/* floating-point-type */ laguerre( unsigned int n,
                                    /* floating-point-type */ x );
(C++23から)
float       laguerref( unsigned int n, float x );
(2) (C++17以降)
long double laguerrel( unsigned int n, long double x );
(3) (C++17以降)
ヘッダー <cmath> で定義
template< class Integer >
double      laguerre ( unsigned int n, Integer x );
(A) (C++17以降)
1-3) 次数 n および引数 x の非連想 ラゲール多項式を計算します。 パラメータ x の型として、すべての cv 修飾されていない浮動小数点型に対する std::laguerre のオーバーロードが提供されます。(since C++23)
A) すべての整数型に対する追加のオーバーロードが提供されます。これらは double として扱われます。

目次

[edit] パラメータ

n - 多項式の次数、符号なし整数値
x - 引数、浮動小数点数または整数値

[edit] 戻り値

エラーが発生しなかった場合、x の非連想ラゲール多項式の値、すなわち
ex
n!
dn
dxn
(xn
e-x)
が返されます。

[edit] エラー処理

math_errhandling で指定されたとおりにエラーが報告される場合があります。

  • 引数が NaN の場合、NaN が返され、ドメインエラーは報告されません。
  • If x is negative, a domain error may occur
  • If n is greater or equal than 128, the behavior is implementation-defined

[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 でも利用可能です。

ラゲール多項式は、方程式 の多項式解です。

最初のいくつかの多項式は次のとおりです。

Function 多項式
    laguerre(0, x)     1
laguerre(1, x) -x + 1
laguerre(2, x)
1
2
(x2
- 4x + 2)
laguerre(3, x)     
1
6
(-x3
- 9x2
- 18x + 6)
    

追加のオーバーロードは、(A) とまったく同じように提供される必要はありません。整数型の引数 num に対して、 std::laguerre(int_num, num)std::laguerre(int_num, static_cast<double>(num)) と同じ効果を持つことを保証するだけで十分です。

[edit]

#include <cmath>
#include <iostream>
 
double L1(double x)
{
    return -x + 1;
}
 
double L2(double x)
{
    return 0.5 * (x * x - 4 * x + 2);
}
 
int main()
{
    // spot-checks
    std::cout << std::laguerre(1, 0.5) << '=' << L1(0.5) << '\n'
              << std::laguerre(2, 0.5) << '=' << L2(0.5) << '\n'
              << std::laguerre(3, 0.0) << '=' << 1.0 << '\n';
}

出力

0.5=0.5
0.125=0.125
1=1

[edit] 関連項目

ラゲール陪多項式
(関数) [編集]

[edit] 外部リンク

Weisstein, Eric W. "Laguerre Polynomial." From MathWorld — A Wolfram Web Resource.
English 日本語 中文(简体) 中文(繁體)