Boost C++ 库

...世界上最受推崇和设计最精湛的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ Coding Standards

cos_pi - Boost C++ 函数库
PrevUpHomeNext
#include <boost/math/special_functions/cos_pi.hpp>
namespace boost{ namespace math{

template <class T>
calculated-result-type cos_pi(T x);

template <class T, class Policy>
calculated-result-type cos_pi(T x, const Policy&);

}} // namespaces

返回 π  x 的余弦值。

此函数的返回类型使用 结果类型计算规则 计算:当 x 是整数类型时返回 double,否则返回 T。

最后的 Policy 参数是可选的,可用于控制函数的行为:例如如何处理错误,使用何种精度级别等。更多详情请参阅 策略文档

此函数在计算 π·x 的余弦值之前,执行精确的全部整数算术参数约简。

表 8.80. cos_pi 的错误率

GNU C++ 版本 7.1.0
linux
double

GNU C++ 版本 7.1.0
linux
long double

Sun 编译器版本 0x5150
Sun Solaris
long double

Microsoft Visual C++ 版本 14.1
Win32
double

sin_pi 和 cos_pi

最大值 = 0ε (平均值 = 0ε)

最大值 = 0.991ε (平均值 = 0.302ε)

最大值 = 0.991ε (平均值 = 0.302ε)

最大值 = 0.996ε (平均值 = 0.284ε)

sin_pi 和 cos_pi 在整数和半整数附近

最大值 = 0ε (平均值 = 0ε)

最大值 = 0.976ε (平均值 = 0.28ε)

最大值 = 0.976ε (平均值 = 0.28ε)

最大值 = 0.996ε (平均值 = 0.298ε)



PrevUpHomeNext