Skip to content

Commit

Permalink
Hard code std::pow of max double as there's no constexpr pow in msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrlongne committed Aug 18, 2021
1 parent 1450907 commit 402996a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/cdi/CDI.hh
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ constexpr double polylog_series_minus_one_planck(double const x, double const ei
/**
* \brief Integrate the normalized Planckian spectrum from 0 to \f$ x (\frac{h\nu}{kT}) \f$.
*
* \param scaled_freq upper integration limit, scaled by the temperature.
* \param exp_scaled_freq upper integration limit, scaled by an exponential function.
* \param[in] scaled_freq upper integration limit, scaled by the temperature.
* \return integrated normalized Planckian from 0 to x \f$(\frac{h\nu}{kT})\f$
*
* There are 3 cases to consider:
Expand Down Expand Up @@ -246,7 +245,7 @@ constexpr double Planck2Rosseland(double const freq, double const exp_freq) {

// Case 1: if nu/T is sufficiently large, then the evaluation is 0.0.
// this evaluation also prevents overflow when evaluating (nu/T)^4.
if (freq > std::pow(std::numeric_limits<decltype(freq)>::max(), 1.0 / 4.0))
if (freq > 1.15792038e77) // hard-coded pow(numeric_limits<double>::max(), 1/4)
return 0.0;

double const freq_3 = freq * freq * freq;
Expand All @@ -263,10 +262,10 @@ constexpr double Planck2Rosseland(double const freq, double const exp_freq) {
/*! \brief Integrate the normalized Planckian and Rosseland spectra from 0 to \f$ x
* (\frac{h\nu}{kT}) \f$.
*
* \param scaled_freq frequency upper integration limit scaled by temperature
* \param exp_scaled_freq upper integration limit, scaled by an exponential function.
* \param planck Variable to return the Planck integral
* \param rosseland Variable to return the Rosseland integral
* \param[in] scaled_freq frequency upper integration limit scaled by temperature
* \param[in] exp_scaled_freq upper integration limit, scaled by an exponential function.
* \param[in] planck Variable to return the Planck integral
* \param[in] rosseland Variable to return the Rosseland integral
*/
constexpr void integrate_planck_rosseland(double const scaled_freq, double const exp_scaled_freq,
double &planck, double &rosseland) {
Expand Down Expand Up @@ -335,8 +334,8 @@ constexpr double integratePlanckSpectrum(double low, double high, const double T
* and temperature is in K, then low and high must first be multiplied by Planck's constant and
* temperature by Boltzmann's constant before they are passed to this function.
*
* \param low Lower limit of frequency range.
* \param high Higher limit of frequency range.
* \param[in] low Lower limit of frequency range.
* \param[in] high Higher limit of frequency range.
* \param[in] T Temperature (must be greater than 0.0).
* \param[out] planck On return, contains the integrated normalized Planckian from low to high.
* \param[out] rosseland On return, contains the integrated normalized Rosseland from low to high
Expand Down Expand Up @@ -390,9 +389,9 @@ constexpr void integrate_Rosseland_Planckian_Spectrum(double low, double high, d
* and temperature is in K, then low and high must first be multiplied by Planck's constant and
* temperature by Boltzmann's constant before they are passed to this function.
*
* \param low lower frequency bound.
* \param high higher frequency bound.
* \param T the temperature (must be greater than 0.0)
* \param[in] low lower frequency bound.
* \param[in] high higher frequency bound.
* \param[in] T the temperature (must be greater than 0.0)
*
* \return integrated normalized Rosseland from low to high
*/
Expand Down

0 comments on commit 402996a

Please sign in to comment.