std::hermite, std::hermitef, std::hermitel
来自 cppreference.cn
< cpp | numeric | special functions
定义于头文件 <cmath> |
||
(1) | ||
double hermite ( unsigned int n, double x ); float hermite ( unsigned int n, float x ); |
(C++17 起) (C++23 前) |
|
/* floating-point-type */ hermite( unsigned int n, /* floating-point-type */ x ); |
(C++23 起) | |
float hermitef( unsigned int n, float x ); |
(2) | (C++17 起) |
long double hermitel( unsigned int n, long double x ); |
(3) | (C++17 起) |
定义于头文件 <cmath> |
||
template< class Integer > double hermite ( unsigned int n, Integer x ); |
(A) | (C++17 起) |
A) 为所有整数类型提供了额外的重载,这些整数类型被视为 double。
目录 |
[编辑] 参数
n | - | 多项式的阶数 |
x | - | 自变量,浮点值或整数值 |
[编辑] 返回值
如果没有错误发生,则返回阶数为 n 的 x 阶埃尔米特多项式的值,即 (-1)nex2
dn |
dxn |
。
[编辑] 错误处理
错误可能按照 math_errhandling 中的规定报告。
- 如果参数是 NaN,则返回 NaN 且不报告域错误。
- 如果 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 中找到。
埃尔米特多项式是方程 u,,
-2xu,
= -2nu 的多项式解。
前几个是
函数 | 多项式 |
---|---|
hermite(0, x) | 1 |
hermite(1, x) | 2x |
hermite(2, x) | 4x2 - 2 |
hermite(3, x) | 8x3 - 12x |
hermite(4, x) | 16x4 - 48x2 + 12 |
额外的重载不需要完全按照 (A) 的形式提供。它们只需要足以确保对于整数类型的参数 num,std::hermite(int_num, num) 与 std::hermite(int_num, static_cast<double>(num)) 具有相同的效果。
[编辑] 示例
运行此代码
#include <cmath> #include <iostream> double H3(double x) { return 8 * std::pow(x, 3) - 12 * x; } double H4(double x) { return 16 * std::pow(x, 4) - 48 * x * x + 12; } int main() { // spot-checks std::cout << std::hermite(3, 10) << '=' << H3(10) << '\n' << std::hermite(4, 10) << '=' << H4(10) << '\n'; }
输出
7880=7880 155212=155212
[编辑] 参见
(C++17)(C++17)(C++17) |
拉盖尔多项式 (函数) |
(C++17)(C++17)(C++17) |
勒让德多项式 (函数) |
[编辑] 外部链接
Weisstein, Eric W. "Hermite Polynomial." 来自 MathWorld — Wolfram Web Resource。 |