From 7258392baba60c0f4d71ff62ca4e50015cd22ae4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 28 Aug 2025 13:47:46 +0200 Subject: hotpatch: fix `surd` function. Signed-off-by: Amlal El Mahrouss --- dev/LibC++/base_math.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'dev/LibC++') diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h index 94c34e8..220d357 100644 --- a/dev/LibC++/base_math.h +++ b/dev/LibC++/base_math.h @@ -18,6 +18,8 @@ typedef float real_type; #endif namespace std::base_math { +inline constexpr static auto not_a_number = NAN; + /// @brief Power function, with Repeat argument. template inline real_type pow(real_type in) { @@ -39,8 +41,14 @@ inline real_type pow(real_type in) { template inline real_type surd(real_type in) { if (in == 0) return 0; + if (in == 1) return 1; + if (Base == 1) return in; + + auto x = in / Base; + + if (Base == 2) return (x + in / x) / 2; - return pow<1 / Base>(in); + return not_a_number; } /// @brief Linear interpolation equation solver. -- cgit v1.2.3