MCPcopy Create free account
hub / github.com/apache/singa / atan

Function atan

include/half.hpp:3682–3700  ·  view source on GitHub ↗

Arc tangent function. This function is exact to rounding for all rounding modes. See also:** Documentation for [std::atan](https://en.cppreference.com/w/cpp/numeric/math/atan). \param arg function argument \return arc tangent 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

3680 /// \exception FE_INVALID for signaling NaN
3681 /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
3682 inline half atan(half arg)
3683 {
3684 #ifdef HALF_ARITHMETIC_TYPE
3685 return half(detail::binary, detail::float2half<half::round_style>(std::atan(detail::half2float<detail::internal_t>(arg.data_))));
3686 #else
3687 unsigned int abs = arg.data_ & 0x7FFF, sign = arg.data_ & 0x8000;
3688 if(!abs)
3689 return arg;
3690 if(abs >= 0x7C00)
3691 return half(detail::binary, (abs==0x7C00) ? detail::rounded<half::round_style,true>(sign|0x3E48, 0, 1) : detail::signal(arg.data_));
3692 if(abs <= 0x2700)
3693 return half(detail::binary, detail::rounded<half::round_style,true>(arg.data_-1, 1, 1));
3694 int exp = (abs>>10) + (abs<=0x3FF);
3695 detail::uint32 my = (abs&0x3FF) | ((abs>0x3FF)<<10);
3696 detail::uint32 m = (exp>15) ? detail::atan2(my<<19, 0x20000000>>(exp-15), (half::round_style==std::round_to_nearest) ? 26 : 24) :
3697 detail::atan2(my<<(exp+4), 0x20000000, (half::round_style==std::round_to_nearest) ? 30 : 28);
3698 return half(detail::binary, detail::fixed2half<half::round_style,30,false,true,true>(m, 14, sign));
3699 #endif
3700 }
3701
3702 /// Arc tangent function.
3703 /// This function may be 1 ULP off the correctly rounded exact result in ~0.005% of inputs for `std::round_to_nearest`,

Callers

nothing calls this directly

Calls 3

halfClass · 0.85
signalFunction · 0.85
atan2Function · 0.85

Tested by

no test coverage detected