summaryrefslogtreecommitdiffhomepage
path: root/dev/LibC++/base_math.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:05:29 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:05:29 +0100
commitbbe2c77243c541ca7e0075149f5be3262eb89523 (patch)
treeae5d59d299344fd19584a2c3642bacd788e841d4 /dev/LibC++/base_math.h
parentb5adf16a96b9cbb80c74cf30404ed5bcff03ac34 (diff)
feat! breaking changes on necti sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibC++/base_math.h')
-rw-r--r--dev/LibC++/base_math.h88
1 files changed, 0 insertions, 88 deletions
diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h
deleted file mode 100644
index 60b260e..0000000
--- a/dev/LibC++/base_math.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ========================================
-
- Copyright (C) 2024-2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
-
-======================================== */
-
-#pragma once
-
-#include <LibC++/defines.h>
-
-#ifndef NAN
-#define NAN (__builtin_nanf(""))
-#endif // !NAN
-
-/// @file Math.h
-/// @brief Math functions.
-
-#ifdef __LIBCXX_USE_DOUBLE__
-typedef double real_type;
-#else
-typedef float real_type;
-#endif
-
-namespace std::base_math {
-inline constexpr static auto not_a_number = NAN;
-
-/// =========================================================== ///
-/// @brief Power function, with Repeat argument.
-/// =========================================================== ///
-template <size_t Exponent>
-inline real_type pow(real_type in) {
- if (Exponent == 0) return 1; // Any number to the power of 0 is 1.
-
- if (Exponent == 1) return in; // Any number to the power of 1 is itself.
-
- size_t cnt = Exponent;
-
- real_type result = 1;
-
- for (auto i = 0; i < cnt; ++i) result *= in;
-
- return result;
-}
-
-/// =========================================================== ///
-/// @brief Square root function.
-/// =========================================================== ///
-inline real_type sqrt(real_type in) {
- if (in == 0) return 0;
- if (in == not_a_number) return not_a_number;
-
- auto constexpr const static Base = 2;
-
- auto x = in / Base;
-
- for (int i = 0; i < 10; ++i) {
- x = (x + in / x) / Base;
- }
-
- return x;
-}
-
-/// =========================================================== ///
-/// @brief Square of function, with Base template argument.
-/// @param of Base argument to find the square of.
-/// =========================================================== ///
-template <size_t Base>
-inline real_type surd(real_type in) {
- if (in == 0) return 0;
- if (in == 1) return 1;
-
- if (Base == 1) return in;
- if (Base == 2) return sqrt(in);
-
- return not_a_number;
-}
-
-/// =========================================================== ///
-/// @brief Linear interpolation equation solver.
-/// @param from where?
-/// @param to to?
-/// @param Updated diff value according to difference.
-/// =========================================================== ///
-inline real_type lerp(real_type to, real_type from, real_type stat) {
- real_type diff = (to - from);
- return from + (diff * stat);
-}
-} // namespace std::base_math