Skip to content

Commit

Permalink
improve compile time efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
kthohr committed Sep 24, 2022
1 parent 70b1267 commit e50356a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion include/gcem_incl/find_exponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,20 @@ llint_t
find_exponent(const T x, const llint_t exponent)
noexcept
{
return( x < T(1) ? \
return( // < 1
x < T(1e-03) ? \
find_exponent(x * T(1e+04), exponent - llint_t(4)) :
x < T(1e-01) ? \
find_exponent(x * T(1e+02), exponent - llint_t(2)) :
x < T(1) ? \
find_exponent(x * T(10), exponent - llint_t(1)) :
// > 10
x > T(10) ? \
find_exponent(x / T(10), exponent + llint_t(1)) :
x > T(1e+02) ? \
find_exponent(x / T(1e+02), exponent + llint_t(2)) :
x > T(1e+04) ? \
find_exponent(x / T(1e+04), exponent + llint_t(4)) :
// else
exponent );
}
Expand Down
8 changes: 4 additions & 4 deletions include/gcem_incl/sqrt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ sqrt_simplify(const T x, const T m_val)
noexcept
{
return( x > T(1e+08) ? \
sqrt_simplify(x / T(1e+08), T(10000) * m_val) :
sqrt_simplify(x / T(1e+08), T(1e+04) * m_val) :
x > T(1e+06) ? \
sqrt_simplify(x / T(1e+06), T(1000) * m_val) :
x > T(10000) ? \
sqrt_simplify(x / T(10000), T(100) * m_val) :
sqrt_simplify(x / T(1e+06), T(1e+03) * m_val) :
x > T(1e+04) ? \
sqrt_simplify(x / T(1e+04), T(1e+02) * m_val) :
x > T(100) ? \
sqrt_simplify(x / T(100), T(10) * m_val) :
x > T(4) ? \
Expand Down

0 comments on commit e50356a

Please sign in to comment.