Skip to content

Commit

Permalink
add C++14 version of tanh
Browse files Browse the repository at this point in the history
  • Loading branch information
kthohr committed Jun 25, 2023
1 parent 0b7eb4b commit ff96a61
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/gcem_incl/tanh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@
namespace internal
{

#if __cplusplus >= 201402L // C++14 version

template<typename T>
constexpr
T
tanh_cf(const T xx, const int depth_end)
noexcept
{
int depth = GCEM_TANH_MAX_ITER - 1;
T res = T(2*(depth+1) - 1);

while (depth > depth_end - 1) {
res = T(2*depth - 1) + xx / res;

--depth;
}

return res;
}

#else // C++11 version

template<typename T>
constexpr
T
Expand All @@ -41,6 +63,8 @@ noexcept
T(2*depth - 1) );
}

#endif

template<typename T>
constexpr
T
Expand Down

0 comments on commit ff96a61

Please sign in to comment.