From: Wolfgang Bangerth Date: Tue, 9 Jan 2024 20:31:48 +0000 (-0700) Subject: Make Utilities::pow() available for floating point types. X-Git-Tag: relicensing~182^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba32c7380ef5eada4f59b0d2ba9a37f28fb41893;p=dealii.git Make Utilities::pow() available for floating point types. --- diff --git a/include/deal.II/base/utilities.h b/include/deal.II/base/utilities.h index 30dc5684b6..5c5a1252ec 100644 --- a/include/deal.II/base/utilities.h +++ b/include/deal.II/base/utilities.h @@ -437,12 +437,15 @@ namespace Utilities T fixed_power(const T t); + /** * A replacement for std::pow that allows compile-time - * calculations for constant expression arguments. The @p base must - * be an integer type and the exponent @p iexp must not be negative. + * calculations for constant expression arguments and if the exponent + * is a positive integer. The @p base must be an arithmetic type + * (i.e., an integer or floating point type), + * and the exponent @p iexp must not be negative. */ - template + template >> constexpr DEAL_II_HOST_DEVICE T pow(const T base, const int iexp) { @@ -477,8 +480,6 @@ namespace Utilities # endif # endif #endif - static_assert(std::is_integral_v, "Only integral types supported"); - // The "exponentiation by squaring" algorithm used below has to be expressed // in an iterative version since SYCL doesn't allow recursive functions used // in device code.