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

Function exp

include/half.hpp:2935–2961  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2933 /// \exception FE_INVALID for signaling NaN
2934 /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
2935 inline half exp(half arg)
2936 {
2937 #ifdef HALF_ARITHMETIC_TYPE
2938 return half(detail::binary, detail::float2half<half::round_style>(std::exp(detail::half2float<detail::internal_t>(arg.data_))));
2939 #else
2940 int abs = arg.data_ & 0x7FFF;
2941 if(!abs)
2942 return half(detail::binary, 0x3C00);
2943 if(abs >= 0x7C00)
2944 return half(detail::binary, (abs==0x7C00) ? (0x7C00&((arg.data_>>15)-1U)) : detail::signal(arg.data_));
2945 if(abs >= 0x4C80)
2946 return half(detail::binary, (arg.data_&0x8000) ? detail::underflow<half::round_style>() : detail::overflow<half::round_style>());
2947 detail::uint32 m = detail::multiply64(static_cast<detail::uint32>((abs&0x3FF)+((abs>0x3FF)<<10))<<21, 0xB8AA3B29);
2948 int e = (abs>>10) + (abs<=0x3FF), exp;
2949 if(e < 14)
2950 {
2951 exp = 0;
2952 m >>= 14 - e;
2953 }
2954 else
2955 {
2956 exp = m >> (45-e);
2957 m = (m<<(e-14)) & 0x7FFFFFFF;
2958 }
2959 return half(detail::binary, detail::exp2_post<half::round_style,true>(detail::exp2(m, 26), exp, (arg.data_&0x8000)!=0));
2960 #endif
2961 }
2962
2963 /// Binary exponential.
2964 /// This function is exact to rounding for all rounding modes.

Callers 8

TESTFunction · 0.50
TEST_FFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TEST_FFunction · 0.50
Cpp>Method · 0.50
Cuda>Method · 0.50

Calls 4

halfClass · 0.85
signalFunction · 0.85
multiply64Function · 0.85
exp2Function · 0.85

Tested by 6

TESTFunction · 0.40
TEST_FFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TEST_FFunction · 0.40