Namespaces
Variants

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

From cppreference.net
定义于头文件 <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 前)
/* 浮点类型 */ laguerre ( unsigned int n,
/* 浮点类型 */ 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 该库为所有 cv 未限定浮点类型提供了 std::laguerre 的重载版本,作为参数 x 的类型。 (C++23 起)
A) 为所有整数类型提供了额外的重载,这些类型将被视为 double

目录

参数

n - 多项式次数,无符号整数值
x - 函数参数,浮点数或整数值

返回值

If no errors occur, value of the nonassociated Laguerre polynomial of x , that is
e x
n!
d n
dx n
(x n
e -x )
, is returned.

错误处理

错误报告方式遵循 math_errhandling 规范

  • 若参数为 NaN,则返回 NaN 且不报告定义域错误
  • x 为负数,可能出现定义域错误
  • 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 中找到。

拉盖尔多项式是方程 的多项式解。

前几个是:

函数 多项式
laguerre ( 0 , x ) 1
laguerre ( 1 , x ) -x + 1
laguerre ( 2 , x )
1
2
(x 2
- 4x + 2)
laguerre ( 3 , x )
1
6
(-x 3
- 9x 2
- 18x + 6)

额外的重载不需要完全按照 (A) 的形式提供。只需确保对于整数类型的实参 num std :: laguerre ( int_num, num ) std :: laguerre ( int_num, static_cast < double > ( num ) ) 具有相同效果即可。

示例

#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()
{
    // 点校验
    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

参见

关联拉盖尔多项式
(函数)

外部链接

韦斯坦,埃里克·W。《拉盖尔多项式》。 摘自 MathWorld —— 一个 Wolfram 网络资源。