std::sph_legendre, std::sph_legendref, std::sph_legendrel
来自cppreference.com
< cpp | numeric | special functions
在标头 <cmath> 定义 | ||
(1) | ||
float sph_legendre (unsigned l, unsigned m, float theta ); double sph_legendre (unsigned l, unsigned m, double theta ); | (C++17 起) (C++23 前) | |
/* 浮点数类型 */ sph_legendre(unsigned l, unsigned m, /* 浮点数类型 */ theta ); | (C++23 起) | |
float sph_legendref(unsigned l, unsigned m, float theta ); | (2) | (C++17 起) |
longdouble sph_legendrel(unsigned l, unsigned m, longdouble theta ); | (3) | (C++17 起) |
在标头 <cmath> 定义 | ||
template<class Integer > double sph_legendre (unsigned l, unsigned m, Integer theta ); | (A) | (C++17 起) |
1-3) 计算 l 次、m 阶和极角 theta 的球关联勒让德函数。标准库提供所有以无 cv 限定的浮点数类型作为形参 theta 的类型的
std::sph_legendre
重载。(C++23 起)A) 为所有整数类型提供额外重载,将它们当做 double。
目录 |
[编辑]参数
l | - | 次数 |
m | - | 阶数 |
theta | - | 极角,以弧度度量 |
[编辑]返回值
如果没有发生错误,那么返回 l、m 和 theta 的球关联勒让德函数(即 ϕ = 0 下的球谐函数)的值,其中球谐函数定义为 Yml(theta,ϕ) = (-1)m
[
(2l+1)(l-m)! |
4π(l+m)! |
Pm
l(cos(theta))eimϕ
,其中 Pm
l(x) 是 std::assoc_legendre(l, m, x)) 且 |m|≤l。
注意此函数定义包含 Condon-Shortley 相位项(-1)m
,因为以 std::assoc_legendre 定义的 Pm
l 忽略了它。
[编辑]错误处理
可能报告 math_errhandling 中指定的错误。
- 如果实参是 NaN,那么返回 NaN 且不报告定义域错误
- 如果 l≥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,且它在以设为零的参数 phi
调用时规约到此函数。
额外重载不需要严格以 (A) 的形式提供。它们只需要能够对它们的整数类型实参 num 确保 std::sph_legendre(int_num1, int_num2, num) 和 std::sph_legendre(int_num1, int_num2, static_cast<double>(num)) 的效果相同即可。
[编辑]示例
运行此代码
输出:
Y_3^0(1.2345) = -0.302387 准确解 = -0.302387
[编辑]参阅
(C++17)(C++17)(C++17) | 连带勒让德多项式 (函数) |
[编辑]外部链接
Weisstein, Eric W. “球谐”来自 MathWorld--A Wolfram Web Resource。 |