From d15b5277cf8b346c1fd16af86979a1d26f19f594 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 24 Oct 2023 10:23:32 -0600 Subject: [PATCH] Make a bunch of arguments 'const'. --- source/base/mu_parser_internal.cc | 71 +++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/source/base/mu_parser_internal.cc b/source/base/mu_parser_internal.cc index 1f86157fc6..7c26d31cda 100644 --- a/source/base/mu_parser_internal.cc +++ b/source/base/mu_parser_internal.cc @@ -36,13 +36,17 @@ namespace internal namespace FunctionParser { int - mu_round(double val) + mu_round(const double val) { return static_cast(val + ((val >= 0.0) ? 0.5 : -0.5)); } + + double - mu_if(double condition, double thenvalue, double elsevalue) + mu_if(const double condition, + const double thenvalue, + const double elsevalue) { if (mu_round(condition) != 0) return thenvalue; @@ -50,84 +54,110 @@ namespace internal return elsevalue; } + + double - mu_or(double left, double right) + mu_or(const double left, const double right) { return static_cast((mu_round(left) != 0) || (mu_round(right) != 0)); } + + double - mu_and(double left, double right) + mu_and(const double left, const double right) { return static_cast((mu_round(left) != 0) && (mu_round(right) != 0)); } + + double - mu_int(double value) + mu_int(const double value) { return static_cast(mu_round(value)); } + + double - mu_ceil(double value) + mu_ceil(const double value) { return std::ceil(value); } + + double - mu_floor(double value) + mu_floor(const double value) { return std::floor(value); } + + double - mu_cot(double value) + mu_cot(const double value) { return 1.0 / std::tan(value); } + + double - mu_csc(double value) + mu_csc(const double value) { return 1.0 / std::sin(value); } + + double - mu_sec(double value) + mu_sec(const double value) { return 1.0 / std::cos(value); } + + double - mu_log(double value) + mu_log(const double value) { return std::log(value); } + + double - mu_pow(double a, double b) + mu_pow(const double a, const double b) { return std::pow(a, b); } + + double - mu_erf(double value) + mu_erf(const double value) { return std::erf(value); } + + double - mu_erfc(double value) + mu_erfc(const double value) { return std::erfc(value); } - // returns a random value in the range [0,1] initializing the generator - // with the given seed + + + // Returns a random value in the range [0,1], after initializing the + // generator with the given seed double - mu_rand_seed(double seed) + mu_rand_seed(const double seed) { static std::mutex rand_mutex; std::lock_guard lock(rand_mutex); @@ -144,7 +174,8 @@ namespace internal return uniform_distribution(rng_map[seed]); } - // returns a random value in the range [0,1] + + // Returns a random value in the range [0,1] double mu_rand() { @@ -156,6 +187,8 @@ namespace internal return uniform_distribution(rng); } + + std::vector get_function_names() { @@ -223,6 +256,8 @@ namespace internal }; #endif + + template ParserImplementation::ParserImplementation() : initialized(false) -- 2.39.5