std::acosh, std::acoshf, std::acoshl
來自 cppreference.com
定義於標頭檔案 <cmath> |
||
(1) | ||
float acosh ( float num ); double acosh ( double num ); |
(直至 C++23) | |
/*floating-point-type*/ acosh ( /*floating-point-type*/ num ); |
(C++23 起) (C++26 起為 constexpr) |
|
float acoshf( float num ); |
(2) | (C++11 起) (C++26 起為 constexpr) |
long double acoshl( long double num ); |
(3) | (C++11 起) (C++26 起為 constexpr) |
SIMD 過載 (C++26 起) |
||
定義於標頭檔案 <simd> |
||
template< /*數學浮點型別*/ V > constexpr /*推導 SIMD 型別*/<V> |
(S) | (C++26 起) |
額外過載 (自 C++11 起) |
||
定義於標頭檔案 <cmath> |
||
template< class Integer > double acosh ( Integer num ); |
(A) | (C++26 起為 constexpr) |
1-3) 計算 num 的反雙曲餘弦。庫為所有 cv 非限定浮點型別提供了
std::acosh
的過載作為引數型別。 庫為所有 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 時返回 NaN)。
[編輯] 錯誤處理
錯誤按 math_errhandling 指定的方式報告。
如果引數小於 1,則會發生域錯誤。
如果實現支援 IEEE 浮點運算 (IEC 60559),
- 如果引數小於 1,則會引發 FE_INVALID 並返回 NaN。
- 如果引數是 1,返回 +0。
- 如果引數是 +∞,返回 +∞。
- 如果引數為 NaN,則返回 NaN。
[編輯] 注意
儘管 C 標準(C++ 在此函式上引用該標準)將此函式命名為“反雙曲餘弦”,但雙曲函式的反函式是面積函式。它們的引數是雙曲扇形的面積,而不是弧。正確的名稱是“反雙曲餘弦”(POSIX 使用)或“面積雙曲餘弦”。
不需要完全按照 (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. "反雙曲餘弦。" 來自 MathWorld — Wolfram Web 資源。 |