std::laguerre, std::laguerref, std::laguerrel
来自 cppreference.cn
< cpp | experimental | 特殊函数
double laguerre( unsigned int n, double x ); double laguerre( unsigned int n, float x ); |
(1) | |
double laguerre( unsigned int n, IntegralType x ); |
(2) | |
1) 计算度为 n 和自变量为 x 的非缔合拉盖尔多项式。
2) 一组重载或接受任何整型参数的函数模板。等价于将参数强制转换为 double 后的 (1)。
与所有特殊函数一样,只有当实现将 __STDCPP_MATH_SPEC_FUNCS__
定义为至少 201003L 的值,并且用户在包含任何标准库头文件之前定义了 __STDCPP_WANT_MATH_SPEC_FUNCS__
时,才能保证 laguerre
在 <cmath>
中可用。
目录 |
[编辑] 参数
n | - | 多项式的度,无符号整数类型的值 |
x | - | 自变量,浮点型或整型的值 |
[编辑] 返回值
如果没有错误发生,则返回 x 的非缔合拉盖尔多项式的值,即ex |
n! |
dn |
dxn |
e-x)。
[编辑] 错误处理
错误可能按照 math_errhandling 中的规定报告。
- 如果参数是 NaN,则返回 NaN 且不报告域错误。
- 如果 x 为负数,则可能发生域错误。
- 如果 n 大于或等于 128,则行为是实现定义的。
[编辑] 注解
不支持 TR 29124 但支持 TR 19768 的实现,在头文件 tr1/cmath
和命名空间 std::tr1
中提供此函数。
此函数的实现也可在 boost.math 中找到。
拉盖尔多项式是方程 xy,,
+ (1 - x)y,
+ ny = 0 的多项式解。
前几个是
- laguerre(0, x) = 1.
- laguerre(1, x) = -x + 1.
- laguerre(2, x) =
[x21 2
- 4x + 2]. - laguerre(3, x) =
[-x31 6
- 9x2
- 18x + 6].
[编辑] 示例
(works as shown with gcc 6.0)
Run this code
#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 #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'; }
Output
0.5=0.5 0.125=0.125
[编辑] 参见
缔合拉盖尔多项式 (函数) |