std::acosh, std::acoshf, std::acoshl
来自 cppreference.cn
定义于头文件 <cmath> |
||
(1) | ||
float acosh ( float num ); double acosh ( double num ); |
(直到 C++23) | |
/*浮点类型*/ acosh ( /*浮点类型*/ num ); |
(自 C++23 起) (constexpr 自 C++26 起) |
|
float acoshf( float num ); |
(2) | (自 C++11 起) (constexpr 自 C++26 起) |
long double acoshl( long double num ); |
(3) | (自 C++11 起) (constexpr 自 C++26 起) |
SIMD 重载 (自 C++26 起) |
||
定义于头文件 <simd> |
||
template< /*math-floating-point*/ V > constexpr /*deduced-simd-t*/<V> |
(S) | (自 C++26 起) |
附加重载 (自 C++11 起) |
||
定义于头文件 <cmath> |
||
template< class Integer > double acosh ( Integer num ); |
(A) | (constexpr 自 C++26 起) |
1-3) 计算 num 的反双曲余弦。 库为所有 cv 限定的浮点类型作为参数类型提供了
std::acosh
的重载。(自 C++23 起)
S) SIMD 重载对 v_num 执行元素级
std::acosh 。
|
(自 C++26 起) |
A) 为所有整数类型提供了附加重载,它们被视为 double。
|
(自 C++11 起) |
目录 |
[编辑] 参数
num | - | 浮点值或整数值 |
[编辑] 返回值
如果没有错误发生,则返回 num 的反双曲余弦 (cosh-1
(num), 或 arcosh(num)) 在区间 [0, +∞] 上。
如果发生域错误,则返回实现定义的数值(如果支持则为 NaN)。
[编辑] 错误处理
错误报告按照 math_errhandling 中指定的进行。
如果参数小于 1,则会发生域错误。
如果实现支持 IEEE 浮点算术 (IEC 60559),
- 如果参数小于 1,则会引发 FE_INVALID 并返回 NaN。
- 如果参数为 1,则返回 +0。
- 如果参数为 +∞,则返回 +∞。
- 如果参数为 NaN,则返回 NaN。
[编辑] 注解
尽管 C 标准(C++ 参考此标准来定义此函数)将此函数命名为 "arc hyperbolic cosine"(反双曲余弦),但双曲函数的反函数是面积函数。它们的参数是双曲扇形的面积,而不是弧长。正确的名称是 "inverse hyperbolic cosine"(反双曲余弦)(POSIX 使用的名称)或 "area hyperbolic cosine"(面积双曲余弦)。
附加重载不需要完全按照 (A) 的形式提供。它们只需要足以确保对于整数类型的参数 num,std::acosh(num) 具有与 std::acosh(static_cast<double>(num)) 相同的效果。
[编辑] 示例
运行此代码
#include <cerrno> #include <cfenv> #include <cfloat> #include <cmath> #include <cstring> #include <iostream> // #pragma STDC FENV_ACCESS ON int main() { std::cout << "acosh(1) = " << std::acosh(1) << '\n' << "acosh(10) = " << std::acosh(10) << '\n' << "acosh(DBL_MAX) = " << std::acosh(DBL_MAX) << '\n' << "acosh(Inf) = " << std::acosh(INFINITY) << '\n'; // error handling errno = 0; std::feclearexcept(FE_ALL_EXCEPT); std::cout << "acosh(0.5) = " << std::acosh(0.5) << '\n'; if (errno == EDOM) std::cout << " errno == EDOM: " << std::strerror(errno) << '\n'; if (std::fetestexcept(FE_INVALID)) std::cout << " FE_INVALID raised\n"; }
可能的输出
acosh(1) = 0 acosh(10) = 2.99322 acosh(DBL_MAX) = 710.476 acosh(Inf) = inf acosh(0.5) = -nan errno == EDOM: Numerical argument out of domain FE_INVALID raised
[编辑] 参见
(C++11)(C++11)(C++11) |
计算反双曲正弦 (arsinh(x)) (函数) |
(C++11)(C++11)(C++11) |
计算反双曲正切 (artanh(x)) (函数) |
(C++11)(C++11) |
计算双曲余弦 (cosh(x)) (函数) |
(C++11) |
计算复数的面积双曲余弦 (arcosh(z)) (函数模板) |
C 文档 关于 acosh
|
[编辑] 外部链接
Weisstein, Eric W. "Inverse Hyperbolic Cosine." 来自 MathWorld — Wolfram Web Resource。 |