From c915e103a81697853c3d4f0f0491989f2b479ac1 Mon Sep 17 00:00:00 2001 From: c1ph3r-dev Date: Tue, 21 May 2024 07:41:46 -0400 Subject: [PATCH] Removed unnecessary functions --- Exponential/Exponential.h | 56 ++++----------------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) diff --git a/Exponential/Exponential.h b/Exponential/Exponential.h index 3be3115..436be5b 100644 --- a/Exponential/Exponential.h +++ b/Exponential/Exponential.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace JRAMPERSAD { @@ -38,18 +39,21 @@ namespace JRAMPERSAD template [[nodiscard("MATH::ABS(T) returns a value of type T")]] T ABS(const T& n) noexcept { + static_assert(std::is_integral::value, "Integral required."); return n < 0 ? n * -1 : n; } template [[nodiscard("MATH::NEGATE(T) returns a value of type T")]] T NEGATE(const T& n) noexcept { + static_assert(std::is_integral::value, "Integral required."); return n * -1; } template [[nodiscard("MATH::POW(T, int) returns a value of type T")]] T POW(const T& n, const int& exp) noexcept { + static_assert(std::is_integral::value, "Integral required."); if (exp == 0) return 1; @@ -62,56 +66,6 @@ namespace JRAMPERSAD return res; } - template - [[nodiscard("MATH::SUM(std::vector) returns a value of type T")]] T SUM(const std::vector& vec) noexcept - { - T res{}; - for (auto& val : vec) - res += val; - return res; - } - - template - [[nodiscard]] T MEDIAN(std::vector vec) noexcept - { - std::sort( - vec.begin(), - vec.end(), - [](const auto& lhs, const auto& rhs) { - return lhs < rhs; - }); - - return vec[vec.size() / 2]; - } - - template - [[nodiscard]] double MEAN(const std::vector& vec) noexcept - { - return SUM(vec) / vec.size(); - } - - template - [[noreturn]] void SortASC(std::vector& vec) - { - std::sort( - std::execution::par, - vec.begin(), vec.end(), - [](const auto& lhs, const auto& rhs) { - return lhs < rhs; - }); - } - - template - [[noreturn]] void SortDESC(std::vector& vec) - { - std::sort( - std::execution::par, - vec.begin(), vec.end(), - [](const auto& lhs, const auto& rhs) { - return lhs > rhs; - }); - } - // Genetic Algorithm helper struct struct GA_Solution { @@ -146,7 +100,7 @@ namespace JRAMPERSAD bool bInitialized; - void CanPerform() const { if (!bInitialized) throw std::logic_error("Function object not initialized fully! Please call .SetConstants() to initialize"); } + inline void CanPerform() const { if (!bInitialized) throw std::logic_error("Function object not initialized fully! Please call .SetConstants() to initialize"); } public: // Speicialty function to get the real roots of a Quadratic Function without relying on a Genetic Algorithm to approximate