diff --git a/src/core/include/mp-units/math.h b/src/core/include/mp-units/math.h index 90a6539a7..e6957201a 100644 --- a/src/core/include/mp-units/math.h +++ b/src/core/include/mp-units/math.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -130,10 +131,10 @@ template } /** - * @brief Determines if a number is finite. + * @brief Determines if a quantity is finite. * - * @param a: Number to analyze. - * @return bool: Whether the number is finite or not. + * @param a: Quantity to analyze. + * @return bool: Whether the quantity is finite or not. */ template requires requires(Rep v) { isfinite(v); } || requires(Rep v) { std::isfinite(v); } @@ -144,10 +145,23 @@ template } /** - * @brief Determines if a number is infinite. + * @brief Determines if a quantity point is finite. * - * @param a: Number to analyze. - * @return bool: Whether the number is infinite or not. + * @param a: Quantity point to analyze. + * @return bool: Whether the quantity point is finite or not. + */ +template + requires requires(quantity q) { isfinite(q); } +[[nodiscard]] constexpr bool isfinite(const quantity_point& a) noexcept +{ + return isfinite(a.quantity_ref_from(a.point_origin)); +} + +/** + * @brief Determines if a quantity is infinite. + * + * @param a: Quantity to analyze. + * @return bool: Whether the quantity is infinite or not. */ template requires requires(Rep v) { isinf(v); } || requires(Rep v) { std::isinf(v); } @@ -157,12 +171,25 @@ template return isinf(a.numerical_value_ref_in(a.unit)); } +/** + * @brief Determines if a quantity point is infinite. + * + * @param a: Quantity point to analyze. + * @return bool: Whether the quantity point is infinite or not. + */ +template + requires requires(quantity q) { isinf(q); } +[[nodiscard]] constexpr bool isinf(const quantity_point& a) noexcept +{ + return isinf(a.quantity_ref_from(a.point_origin)); +} + /** - * @brief Determines if a number is a nan. + * @brief Determines if a quantity is a nan. * - * @param a: Number to analyze. - * @return bool: Whether the number is a NaN or not. + * @param a: Quantity to analyze. + * @return bool: Whether the quantity is a NaN or not. */ template requires requires(Rep v) { isnan(v); } || requires(Rep v) { std::isnan(v); } @@ -172,6 +199,20 @@ template return isnan(a.numerical_value_ref_in(a.unit)); } + +/** + * @brief Determines if a quantity point is a nan. + * + * @param a: Quantity point to analyze. + * @return bool: Whether the quantity point is a NaN or not. + */ +template + requires requires(quantity q) { isnan(q); } +[[nodiscard]] constexpr bool isnan(const quantity_point& a) noexcept +{ + return isnan(a.quantity_ref_from(a.point_origin)); +} + /** * @brief Computes the fma of 3 quantities *