Skip to content

Commit

Permalink
Finalize exp docs and add overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Mar 23, 2024
1 parent 50eb8db commit c368d22
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions include/ccmath/math/exponential/exp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,49 @@

namespace ccm
{
template <typename T>
inline constexpr T exp(T x)
/**
* @brief Computes e raised to the given power
* @tparam T floating-point or integer type
* @param num floating-point or integer value
* @return If no errors occur, the base-e exponential of num (e^num) is returned.
*/
template <typename T, std::enable_if_t<!std::is_integral_v<T>, bool> = true>
inline constexpr T exp(T num)
{
if constexpr (std::is_same_v<T, float>) { return ccm::internal::impl::exp_float_impl(x); }
else { return ccm::internal::impl::exp_double_impl(x); }
if constexpr (std::is_same_v<T, float>) { return ccm::internal::impl::exp_float_impl(num); }
else { return ccm::internal::impl::exp_double_impl(num); }
}

/**
* @brief Computes e raised to the given power
* @tparam Integer integer type
* @param num integer value
* @return If no errors occur, the base-e exponential of num (e^num) is returned as double.
*/
template <typename Integer, std::enable_if_t<std::is_integral_v<Integer>, bool> = true>
inline constexpr double exp(Integer num)
{
return ccm::exp<double>(static_cast<double>(num));
}

/**
* @brief Computes e raised to the given power
* @param num floating-point value
* @return If no errors occur, the base-e exponential of num (e^num) is returned as float.
*/
inline constexpr float expf(float num)
{
return ccm::internal::impl::exp_float_impl(num);
}

/**
* @brief Computes e raised to the given power
* @param num floating-point value
* @return If no errors occur, the base-e exponential of num (e^num) is returned as double.
*/
inline constexpr long double expl(long double num)
{
return static_cast<long double>(ccm::exp<double>(static_cast<double>(num)));
}

} // namespace ccm

0 comments on commit c368d22

Please sign in to comment.