diff --git a/src/dimension.h b/src/dimension.h index 0b2093d718a61c6ce850db1970412af3e2e462b9..7084d70f5794853557539862091809071af2e790 100644 --- a/src/dimension.h +++ b/src/dimension.h @@ -89,6 +89,34 @@ __attribute__((always_inline)) INLINE static float pow_dimension(float x) { #endif } +/** + * @brief Returns the argument to the power given by the inverse of the + * dimension + * + * Computes \f$x^{1/d}\f$. + */ +__attribute__((always_inline)) INLINE static float pow_inv_dimension(float x) { + +#if defined(HYDRO_DIMENSION_3D) + + return cbrtf(x); + +#elif defined(HYDRO_DIMENSION_2D) + + return sqrtf(x); + +#elif defined(HYDRO_DIMENSION_1D) + + return x; + +#else + + error("The dimension is not defined !"); + return 0.f; + +#endif +} + /** * @brief Returns the argument to the power given by the dimension plus one *