MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / cosh

Function cosh

include/half_float/half.hpp:3821–3838  ·  view source on GitHub ↗

Hyperbolic cosine. This function is exact to rounding for all rounding modes. See also:** Documentation for [std::cosh](https://en.cppreference.com/w/cpp/numeric/math/cosh). \param arg function argument \return hyperbolic cosine value of \a arg \exception FE_INVALID for signaling NaN \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding

Source from the content-addressed store, hash-verified

3819 /// \exception FE_INVALID for signaling NaN
3820 /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
3821 inline half cosh(half arg)
3822 {
3823 #ifdef HALF_ARITHMETIC_TYPE
3824 return half(detail::binary, detail::float2half<half::round_style>(std::cosh(detail::half2float<detail::internal_t>(arg.data_))));
3825 #else
3826 int abs = arg.data_ & 0x7FFF, exp;
3827 if(!abs)
3828 return half(detail::binary, 0x3C00);
3829 if(abs >= 0x7C00)
3830 return half(detail::binary, (abs>0x7C00) ? detail::signal(arg.data_) : 0x7C00);
3831 std::pair<detail::uint32,detail::uint32> mm = detail::hyperbolic_args(abs, exp, (half::round_style==std::round_to_nearest) ? 23 : 26);
3832 detail::uint32 m = mm.first + mm.second, i = (~m&0xFFFFFFFF) >> 31;
3833 m = (m>>i) | (m&i) | 0x80000000;
3834 if((exp+=13+i) > 29)
3835 return half(detail::binary, detail::overflow<half::round_style>());
3836 return half(detail::binary, detail::fixed2half<half::round_style,31,false,false,true>(m, exp));
3837 #endif
3838 }
3839
3840 /// Hyperbolic tangent.
3841 /// This function is exact to rounding for all rounding modes.

Callers

nothing calls this directly

Calls 3

halfClass · 0.85
signalFunction · 0.85
hyperbolic_argsFunction · 0.85

Tested by

no test coverage detected