diff --git a/.gcov/make/make_gcov_02_files.gmk b/.gcov/make/make_gcov_02_files.gmk index cd8d84d..43973ce 100644 --- a/.gcov/make/make_gcov_02_files.gmk +++ b/.gcov/make/make_gcov_02_files.gmk @@ -11,7 +11,6 @@ FILES_PRJ = $(PATH_SRC)/test/test $(PATH_SRC)/test/test_soft_double_examples \ $(PATH_SRC)/test/test_soft_double_spot_values \ $(PATH_SRC)/examples/example001_roots_sqrt \ - $(PATH_SRC)/examples/example002b_pi_100k \ $(PATH_SRC)/examples/example004_bessel_recur \ $(PATH_SRC)/examples/example005_polylog_series \ $(PATH_SRC)/examples/example007_catalan_series \ diff --git a/.gcov/make/make_gcov_03_flags.gmk b/.gcov/make/make_gcov_03_flags.gmk index 15c4b9e..dc18f80 100644 --- a/.gcov/make/make_gcov_03_flags.gmk +++ b/.gcov/make/make_gcov_03_flags.gmk @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------ -# Copyright Christopher Kormanyos 2022 - 2023. +# Copyright Christopher Kormanyos 2022 - 2024. # Distributed under the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt # or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -76,5 +76,4 @@ LCOV_BRANCH := --rc lcov_branch_coverage=1 endif LCOV_REMOVES = '/usr/*' \ - '*wide_decimal/*' \ - '*util/*' + '*util*' diff --git a/.github/workflows/soft_double.yml b/.github/workflows/soft_double.yml index 225c661..b65815d 100644 --- a/.github/workflows/soft_double.yml +++ b/.github/workflows/soft_double.yml @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------ -# Copyright Christopher Kormanyos 2020 - 2023. +# Copyright Christopher Kormanyos 2020 - 2024. # Distributed under the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt # or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -32,7 +32,7 @@ jobs: run: | echo "compile ./soft_double.exe" ${{ matrix.compiler }} -v - ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -O3 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe + ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -O3 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe ls -la ./soft_double.exe ./soft_double.exe cmake-linux: @@ -130,7 +130,7 @@ jobs: run: | echo "compile ./soft_double.exe" ${{ matrix.compiler }} -v - ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -O3 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe + ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -O3 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe ls -la ./soft_double.exe ./soft_double.exe mingw-winhost-x64: @@ -151,7 +151,7 @@ jobs: run: | echo compile ./soft_double.exe ${{ matrix.compiler }} -v - ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -m64 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe + ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -m64 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe dir .\soft_double.exe .\soft_double.exe gcc-clang-native-asan: @@ -174,7 +174,7 @@ jobs: run: | echo "compile ./soft_double.exe" ${{ matrix.compiler }} -v - ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -std=${{ matrix.standard }} -fsanitize=address -fsanitize=leak -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe + ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -std=${{ matrix.standard }} -fsanitize=address -fsanitize=leak -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe ls -la ./soft_double.exe ./soft_double.exe gcc-clang-native-ubsan: @@ -197,7 +197,7 @@ jobs: run: | echo "compile ./soft_double.exe" ${{ matrix.compiler }} -v - ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -std=${{ matrix.standard }} -fsanitize=undefined -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=unreachable -fsanitize=vla-bound -fsanitize=null -fsanitize=return -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool -fsanitize=enum -fsanitize=vptr -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe + ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -std=${{ matrix.standard }} -fsanitize=undefined -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=unreachable -fsanitize=vla-bound -fsanitize=null -fsanitize=return -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool -fsanitize=enum -fsanitize=vptr -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe ls -la ./soft_double.exe ./soft_double.exe apple-gcc-clang-native: @@ -218,7 +218,7 @@ jobs: run: | echo "compile ./soft_double.exe" ${{ matrix.compiler }} -v - ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -O3 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe + ${{ matrix.compiler }} -finline-functions -O3 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -march=native -O3 -std=${{ matrix.standard }} -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe ls -la ./soft_double.exe ./soft_double.exe msvc-release-x64: diff --git a/.github/workflows/soft_double_codecov.yml b/.github/workflows/soft_double_codecov.yml index 2ea0dfb..660bac4 100644 --- a/.github/workflows/soft_double_codecov.yml +++ b/.github/workflows/soft_double_codecov.yml @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------ -# Copyright Christopher Kormanyos 2022 - 2023. +# Copyright Christopher Kormanyos 2022 - 2024. # Distributed under the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt # or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -44,9 +44,10 @@ jobs: echo "return to wide-integer root directory" cd ../.. - name: upload-codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: files: .gcov/make/coverage.info + env_vars: ubuntu-latest token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - functionalities: fix + verbose: true diff --git a/.github/workflows/soft_double_sonar.yml b/.github/workflows/soft_double_sonar.yml index 2f6bbd1..7121fdb 100644 --- a/.github/workflows/soft_double_sonar.yml +++ b/.github/workflows/soft_double_sonar.yml @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------ -# Copyright Christopher Kormanyos 2022 - 2023. +# Copyright Christopher Kormanyos 2022 - 2024. # Distributed under the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt # or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -48,7 +48,7 @@ jobs: - name: Run build-wrapper run: | java -version - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} g++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++14 -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} g++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++14 -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe - name: Run sonar-scanner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.tidy/make/make_tidy_02_files.gmk b/.tidy/make/make_tidy_02_files.gmk index 1ea54e8..13f4877 100644 --- a/.tidy/make/make_tidy_02_files.gmk +++ b/.tidy/make/make_tidy_02_files.gmk @@ -11,7 +11,6 @@ FILES_PRJ = $(PATH_SRC)/test/test \ $(PATH_SRC)/test/test_soft_double_examples \ $(PATH_SRC)/test/test_soft_double_spot_values \ $(PATH_SRC)/examples/example001_roots_sqrt \ - $(PATH_SRC)/examples/example002b_pi_100k \ $(PATH_SRC)/examples/example004_bessel_recur \ $(PATH_SRC)/examples/example005_polylog_series \ $(PATH_SRC)/examples/example007_catalan_series \ diff --git a/.tidy/make/make_tidy_03_flags.gmk b/.tidy/make/make_tidy_03_flags.gmk index 0d0b209..b2bce2a 100644 --- a/.tidy/make/make_tidy_03_flags.gmk +++ b/.tidy/make/make_tidy_03_flags.gmk @@ -39,9 +39,9 @@ TIDY_CHECKS = "*, \ -altera-unroll-loops, \ -fuchsia-*, \ -llvmlibc-*, \ - -readability-identifier-length" + -readability-identifier-length, \ + -readability-identifier-naming" TIDY_FLAGS = --extra-arg-before=--driver-mode=g++ \ - --header-filter=decwide_t \ -warnings-as-errors=* \ -checks=$(TIDY_CHECKS) diff --git a/README.md b/README.md index 21eaa5a..5edac86 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,6 @@ It is hoped that the examples provide inspiration and guidance on how to use soft_double. - ![`example001_roots_sqrt.cpp`](./examples/example001_roots_sqrt.cpp) computes a square root. - - ![`example002b_pi_100k.cpp`](./examples/example002b_pi_100k.cpp) uses soft_double together with the [wide-decimal](https://github.com/ckormanyos/wide-decimal) project which stresses demanding use of real-world double-precision FFTs to compute $100,001$ decimal digits of $\pi$ using an iterative AGM method. - ![`example004_bessel_recur.cpp`](./examples/example004_bessel_recur.cpp) implements cylindrical Bessel functions of integral order via downward recursion with a Neumann sum. - ![`example005_polylog_series.cpp`](./examples/example005_polylog_series.cpp) performs a small-argument polylogarithm series calculation. - ![`example007_catalan_series.cpp`](./examples/example007_catalan_series.cpp) computes $\sim 15$ decimal digits of Catalan's constant using an accelerated series. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d07bbd4..567e3b2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,5 @@ add_library(Examples example001_roots_sqrt.cpp - example002b_pi_100k.cpp example004_bessel_recur.cpp example005_polylog_series.cpp example007_catalan_series.cpp diff --git a/examples/example002b_pi_100k.cpp b/examples/example002b_pi_100k.cpp deleted file mode 100644 index 1fcc63b..0000000 --- a/examples/example002b_pi_100k.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2012 - 2023. // -// Distributed under the Boost Software License, // -// Version 1.0. (See accompanying file LICENSE_1_0.txt // -// or copy at http://www.boost.org/LICENSE_1_0.txt) // -/////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include -#include - -#define WIDE_DECIMAL_DISABLE_IOSTREAM -#define WIDE_DECIMAL_DISABLE_DYNAMIC_MEMORY_ALLOCATION -#define WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING -#define WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS - -#include -#include -#include -#include - -namespace local -{ - auto example002b_pi_100k_digits10_callback(const std::uint32_t d10) -> void - { - using char_array_type = std::array(UINT8_C(64))>; - - auto p_str = char_array_type { }; - - p_str.fill('\0'); - - auto p_end = static_cast(util::baselexical_cast(d10, p_str.data())); // NOLINT(llvm-qualified-auto,readability-qualified-auto) - - static_cast(p_end); - - const auto str_result = std::string(p_str.data()); - - std::cout << str_result << std::endl; - } -} // namespace local - -auto math::softfloat::example002b_pi_100k() -> bool -{ - std::cout << "Start example002b_pi_100k()" << std::endl; - - using local_limb_type = std::uint32_t; - - constexpr std::uint32_t wide_decimal_digits10 = UINT32_C(100001); - - constexpr std::int32_t local_elem_digits10 = - math::wide_decimal::detail::decwide_t_helper::elem_digits10; - - using local_float_type = math::softfloat::float64_t; - using local_float_type_fft = local_float_type; - - using local_wide_decimal_type = - math::wide_decimal::decwide_t, - local_float_type_fft, - std::int32_t, - local_float_type>; - - const auto start = std::clock(); - - const local_wide_decimal_type my_pi = - math::wide_decimal::pi, local_float_type_fft, std::int32_t, local_float_type> - ( - local::example002b_pi_100k_digits10_callback - ); - - const auto stop = std::clock(); - - std::cout << "Time example002b_pi_100k() : " - << static_cast(stop - start) / static_cast(CLOCKS_PER_SEC) - << std::endl; - - const bool head_is_ok = std::equal(my_pi.crepresentation().cbegin(), - my_pi.crepresentation().cbegin() + math::constants::const_pi_control_head_32.size(), - math::constants::const_pi_control_head_32.begin()); - - using const_iterator_type = typename local_wide_decimal_type::representation_type::const_iterator; - - const_iterator_type - fi - ( - my_pi.crepresentation().cbegin() - + static_cast( static_cast(1UL + ((wide_decimal_digits10 - 1UL) / local_elem_digits10)) - - static_cast(math::constants::const_pi_control_tail_32_100001.size())) - ); - - const bool tail_is_ok = std::equal(fi, - fi + math::constants::const_pi_control_tail_32_100001.size(), - math::constants::const_pi_control_tail_32_100001.begin()); - - const bool result_pi_is_ok = (head_is_ok && tail_is_ok); - - const auto flg = std::cout.flags(); - - std::cout << "result_pi_is_ok : " << std::boolalpha << result_pi_is_ok << std::endl; - - std::cout.flags(flg); - - return result_pi_is_ok; -} - -// Enable this if you would like to activate this main() as a standalone example. -#if 0 - -#include -#include - -int main() -{ - const bool result_is_ok = math::softfloat::example002b_pi_100k(); - - std::cout << "result_is_ok: " << std::boolalpha << result_is_ok << std::endl; -} - -#endif diff --git a/math/constants/constants_pi_control_for_decwide_t.h b/math/constants/constants_pi_control_for_decwide_t.h deleted file mode 100644 index ad05b96..0000000 --- a/math/constants/constants_pi_control_for_decwide_t.h +++ /dev/null @@ -1,190 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020 - 2022. -// Distributed under the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt -// or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef CONSTANTS_PI_CONTROL_FOR_DECWIDE_T_2020_11_21_H // NOLINT(llvm-header-guard) - #define CONSTANTS_PI_CONTROL_FOR_DECWIDE_T_2020_11_21_H - - #include - #include - #include - - #include - - WIDE_DECIMAL_NAMESPACE_BEGIN - - #if(__cplusplus >= 201703L) - namespace math::constants { - #else - namespace math { namespace constants { // NOLINT(modernize-concat-nested-namespaces) - #endif - - constexpr std::array(UINT8_C(7) + UINT8_C(1))> const_pi_control_head_32 - { - // head std::uint32_t - static_cast(UINT32_C(3)), - static_cast(UINT32_C(14159265)), - static_cast(UINT32_C(35897932)), - static_cast(UINT32_C(38462643)), - static_cast(UINT32_C(38327950)), - static_cast(UINT32_C(28841971)), - static_cast(UINT32_C(69399375)), - static_cast(UINT32_C(10582097)) - }; - - constexpr std::array(UINT8_C(14) + UINT8_C(1))> const_pi_control_head_16 - { - // head std::uint16_t - static_cast(UINT16_C(3)), - static_cast(UINT16_C(1415)), static_cast(UINT16_C(9265)), - static_cast(UINT16_C(3589)), static_cast(UINT16_C(7932)), - static_cast(UINT16_C(3846)), static_cast(UINT16_C(2643)), - static_cast(UINT16_C(3832)), static_cast(UINT16_C(7950)), - static_cast(UINT16_C(2884)), static_cast(UINT16_C(1971)), - static_cast(UINT16_C(6939)), static_cast(UINT16_C(9375)), - static_cast(UINT16_C(1058)), static_cast(UINT16_C(2097)) - }; - - constexpr std::array(UINT8_C(28) + UINT8_C(1))> const_pi_control_head_08 - { - // head std::uint8_t - static_cast(UINT8_C(3)), - static_cast(UINT8_C(14)), static_cast(UINT8_C(15)), static_cast(UINT8_C(92)), static_cast(UINT8_C(65)), - static_cast(UINT8_C(35)), static_cast(UINT8_C(89)), static_cast(UINT8_C(79)), static_cast(UINT8_C(32)), - static_cast(UINT8_C(38)), static_cast(UINT8_C(46)), static_cast(UINT8_C(26)), static_cast(UINT8_C(43)), - static_cast(UINT8_C(38)), static_cast(UINT8_C(32)), static_cast(UINT8_C(79)), static_cast(UINT8_C(50)), - static_cast(UINT8_C(28)), static_cast(UINT8_C(84)), static_cast(UINT8_C(19)), static_cast(UINT8_C(71)), - static_cast(UINT8_C(69)), static_cast(UINT8_C(39)), static_cast(UINT8_C(93)), static_cast(UINT8_C(75)), - static_cast(UINT8_C(10)), static_cast(UINT8_C(58)), static_cast(UINT8_C(20)), static_cast(UINT8_C(97)) - }; - - constexpr std::array(UINT8_C(8))> const_pi_control_tail_32_10001 - { - // tail 1 + 10^4 std::uint32_t - static_cast(UINT32_C(29552498)), - static_cast(UINT32_C(87275846)), - static_cast(UINT32_C(10126483)), - static_cast(UINT32_C(69998922)), - static_cast(UINT32_C(56959688)), - static_cast(UINT32_C(15920560)), - static_cast(UINT32_C( 1016552)), - static_cast(UINT32_C(56375678)) - }; - - constexpr std::array(UINT8_C(8))> const_pi_control_tail_32_100001 - { - // tail 1 + 10^5 std::uint32_t - static_cast(UINT32_C(38043299)), - static_cast(UINT32_C(70695770)), - static_cast(UINT32_C(15078933)), - static_cast(UINT32_C(77286580)), - static_cast(UINT32_C(35712790)), - static_cast(UINT32_C(91376742)), - static_cast(UINT32_C( 8056554)), - static_cast(UINT32_C(93624646)) - }; - - constexpr std::array(UINT8_C(8))> const_pi_control_tail_32_1000001 - { - // tail 1 + 10^6 std::uint32_t - static_cast(UINT32_C(20875424)), - static_cast(UINT32_C(50598956)), - static_cast(UINT32_C(78796130)), - static_cast(UINT32_C(33116462)), - static_cast(UINT32_C(83996346)), - static_cast(UINT32_C(46042209)), - static_cast(UINT32_C( 1061057)), - static_cast(UINT32_C(79458151)) - }; - - constexpr std::array(UINT8_C(16))> const_pi_control_tail_16_10001 - { - // tail 1 + 10^4 std::uint16_t - static_cast(UINT16_C(2955)), static_cast(UINT16_C(2498)), - static_cast(UINT16_C(8727)), static_cast(UINT16_C(5846)), - static_cast(UINT16_C(1012)), static_cast(UINT16_C(6483)), - static_cast(UINT16_C(6999)), static_cast(UINT16_C(8922)), - static_cast(UINT16_C(5695)), static_cast(UINT16_C(9688)), - static_cast(UINT16_C(1592)), static_cast(UINT16_C( 560)), - static_cast(UINT16_C( 101)), static_cast(UINT16_C(6552)), - static_cast(UINT16_C(5637)), static_cast(UINT16_C(5678)) - }; - - constexpr std::array(UINT8_C(16))> const_pi_control_tail_16_100001 - { - // tail 1 + 10^5 std::uint16_t - static_cast(UINT16_C(3804)), static_cast(UINT16_C(3299)), - static_cast(UINT16_C(7069)), static_cast(UINT16_C(5770)), - static_cast(UINT16_C(1507)), static_cast(UINT16_C(8933)), - static_cast(UINT16_C(7728)), static_cast(UINT16_C(6580)), - static_cast(UINT16_C(3571)), static_cast(UINT16_C(2790)), - static_cast(UINT16_C(9137)), static_cast(UINT16_C(6742)), - static_cast(UINT16_C( 805)), static_cast(UINT16_C(6554)), - static_cast(UINT16_C(9362)), static_cast(UINT16_C(4646)) - }; - - constexpr std::array(UINT8_C(16))> const_pi_control_tail_16_1000001 - { - // tail 1 + 10^6 std::uint16_t - static_cast(UINT16_C(2087)), static_cast(UINT16_C(5424)), - static_cast(UINT16_C(5059)), static_cast(UINT16_C(8956)), - static_cast(UINT16_C(7879)), static_cast(UINT16_C(6130)), - static_cast(UINT16_C(3311)), static_cast(UINT16_C(6462)), - static_cast(UINT16_C(8399)), static_cast(UINT16_C(6346)), - static_cast(UINT16_C(4604)), static_cast(UINT16_C(2209)), - static_cast(UINT16_C( 106)), static_cast(UINT16_C(1057)), - static_cast(UINT16_C(7945)), static_cast(UINT16_C(8151)) - }; - - constexpr std::array(UINT8_C(32))> const_pi_control_tail_08_10001 - { - // tail 1 + 10^4 std::uint8_t - static_cast(UINT8_C(29)), static_cast(UINT8_C(55)), static_cast(UINT8_C(24)), static_cast(UINT8_C(98)), - static_cast(UINT8_C(87)), static_cast(UINT8_C(27)), static_cast(UINT8_C(58)), static_cast(UINT8_C(46)), - static_cast(UINT8_C(10)), static_cast(UINT8_C(12)), static_cast(UINT8_C(64)), static_cast(UINT8_C(83)), - static_cast(UINT8_C(69)), static_cast(UINT8_C(99)), static_cast(UINT8_C(89)), static_cast(UINT8_C(22)), - static_cast(UINT8_C(56)), static_cast(UINT8_C(95)), static_cast(UINT8_C(96)), static_cast(UINT8_C(88)), - static_cast(UINT8_C(15)), static_cast(UINT8_C(92)), static_cast(UINT8_C( 5)), static_cast(UINT8_C(60)), - static_cast(UINT8_C( 1)), static_cast(UINT8_C( 1)), static_cast(UINT8_C(65)), static_cast(UINT8_C(52)), - static_cast(UINT8_C(56)), static_cast(UINT8_C(37)), static_cast(UINT8_C(56)), static_cast(UINT8_C(78)) - }; - - constexpr std::array(UINT8_C(32))> const_pi_control_tail_08_100001 - { - // tail 1 + 10^5 std::uint8_t - static_cast(UINT8_C(38)), static_cast(UINT8_C( 4)), static_cast(UINT8_C(32)), static_cast(UINT8_C(99)), - static_cast(UINT8_C(70)), static_cast(UINT8_C(69)), static_cast(UINT8_C(57)), static_cast(UINT8_C(70)), - static_cast(UINT8_C(15)), static_cast(UINT8_C( 7)), static_cast(UINT8_C(89)), static_cast(UINT8_C(33)), - static_cast(UINT8_C(77)), static_cast(UINT8_C(28)), static_cast(UINT8_C(65)), static_cast(UINT8_C(80)), - static_cast(UINT8_C(35)), static_cast(UINT8_C(71)), static_cast(UINT8_C(27)), static_cast(UINT8_C(90)), - static_cast(UINT8_C(91)), static_cast(UINT8_C(37)), static_cast(UINT8_C(67)), static_cast(UINT8_C(42)), - static_cast(UINT8_C( 8)), static_cast(UINT8_C( 5)), static_cast(UINT8_C(65)), static_cast(UINT8_C(54)), - static_cast(UINT8_C(93)), static_cast(UINT8_C(62)), static_cast(UINT8_C(46)), static_cast(UINT8_C(46)) - }; - - constexpr std::array(UINT8_C(32))> const_pi_control_tail_08_1000001 - { - // tail 1 + 10^6 std::uint8_t - static_cast(UINT8_C(20)), static_cast(UINT8_C(87)), static_cast(UINT8_C(54)), static_cast(UINT8_C(24)), - static_cast(UINT8_C(50)), static_cast(UINT8_C(59)), static_cast(UINT8_C(89)), static_cast(UINT8_C(56)), - static_cast(UINT8_C(78)), static_cast(UINT8_C(79)), static_cast(UINT8_C(61)), static_cast(UINT8_C(30)), - static_cast(UINT8_C(33)), static_cast(UINT8_C(11)), static_cast(UINT8_C(64)), static_cast(UINT8_C(62)), - static_cast(UINT8_C(83)), static_cast(UINT8_C(99)), static_cast(UINT8_C(63)), static_cast(UINT8_C(46)), - static_cast(UINT8_C(46)), static_cast(UINT8_C( 4)), static_cast(UINT8_C(22)), static_cast(UINT8_C( 9)), - static_cast(UINT8_C( 1)), static_cast(UINT8_C( 6)), static_cast(UINT8_C(10)), static_cast(UINT8_C(57)), - static_cast(UINT8_C(79)), static_cast(UINT8_C(45)), static_cast(UINT8_C(81)), static_cast(UINT8_C(51)) - }; - - #if(__cplusplus >= 201703L) - } // namespace math::constants - #else - } // namespace constants - } // namespace math - #endif - - WIDE_DECIMAL_NAMESPACE_END - -#endif // CONSTANTS_PI_CONTROL_FOR_DECWIDE_T_2020_11_21_H diff --git a/math/softfloat/soft_double.h b/math/softfloat/soft_double.h index 2d24c2a..ef006f8 100644 --- a/math/softfloat/soft_double.h +++ b/math/softfloat/soft_double.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2012 - 2023. // +// Copyright Christopher Kormanyos 2012 - 2024. // // Distributed under the Boost Software License, // // Version 1.0. (See accompanying file LICENSE_1_0.txt // // or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -45,7 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -----------------------------------------------------------------------------*/ -#ifndef SOFT_DOUBLE_2020_10_27_H +#ifndef SOFT_DOUBLE_2020_10_27_H // NOLINT(llvm-header-guard) #define SOFT_DOUBLE_2020_10_27_H //#define SOFT_DOUBLE_DISABLE_IOSTREAM @@ -592,6 +592,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. constexpr auto sin (soft_double x) -> soft_double; constexpr auto cos (soft_double x) -> soft_double; constexpr auto tan (soft_double x) -> soft_double; + constexpr auto asin (soft_double x) -> soft_double; + constexpr auto acos (soft_double x) -> soft_double; + constexpr auto atan (soft_double x) -> soft_double; constexpr auto sinh (soft_double x) -> soft_double; constexpr auto cosh (soft_double x) -> soft_double; constexpr auto tanh (soft_double x) -> soft_double; @@ -727,7 +730,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } template - SOFT_DOUBLE_NODISCARD constexpr auto to_float() const -> typename std::enable_if<( (sizeof(FloatingPointType) == 8) + SOFT_DOUBLE_NODISCARD constexpr auto to_float() const -> typename std::enable_if<( (sizeof(FloatingPointType) == static_cast(UINT8_C(8))) && std::numeric_limits::is_iec559), FloatingPointType>::type { return static_cast(*static_cast(static_cast(this))); @@ -1826,7 +1829,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if(expA_as_unsigned >= static_cast(UINT16_C(0x7FD))) { - sig = detail::softfloat_shiftRightJam64(sig, static_cast(-expA)); + sig = detail::softfloat_shiftRightJam64(sig, static_cast(-expA)); // LCOV_EXCL_LINE expA = static_cast(INT8_C(0)); } } @@ -1909,7 +1912,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if(expZ < static_cast(INT8_C(0))) { - shiftDist = static_cast(expA); + shiftDist = static_cast(expA); // LCOV_EXCL_LINE expZ = static_cast(INT8_C(0)); } @@ -2116,7 +2119,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. auto y = x; for(auto p_local = static_cast(u); - p_local != static_cast(UINT8_C(0)); + p_local != static_cast(UINT8_C(0)); // NOLINT(altera-id-dependent-backward-branch) p_local = static_cast(p_local >> static_cast(UINT8_C(1)))) { const auto bit_is_set = @@ -2152,7 +2155,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. auto y = x; for(auto p_local = static_cast(n); - p_local != static_cast(UINT8_C(0)); + p_local != static_cast(UINT8_C(0)); // NOLINT(altera-id-dependent-backward-branch) p_local = static_cast(p_local >> static_cast(UINT8_C(1)))) { const auto bit_zero_is_set = @@ -2409,6 +2412,92 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. return soft_double::my_value_one() + ((x2 * top) / (bot * static_cast(INT8_C(24)))); } + constexpr auto asin_pade(soft_double x) -> soft_double // NOLINT(performance-unnecessary-value-param) + { + // Usa a Pade approximation of (asin(x) / x). + // Then simplify, extract the coefficients of numerator and denominator. + // Scale both numeroator and denominator by a factor of 10^29. + // Subsequently extract the integer parts of the coefficients. + + // PadeApproximant[ArcSin[x]/x, {x, 0, {12, 12}}] + // FullSimplify[%] + // IntegerPart[N[CoefficientList[Numerator[Out[2]]/10^29, x^2], 24]] + // IntegerPart[N[CoefficientList[Denominator[Out[2]]/10^29, x^2], 24]] + + // Numerator: + // 140095773199074572 + // -388690947968573359 + // 402271633106633823 + // -190922593544635779 + // 40839234741969911 + // -3218334247465525 + // 45053024618672 + + // Denominator: + // 140095773199074572 + // -412040243501752455 + // 460437824033661973 + // -243013488210192408 + // 60946917703998365 + // -6321063389564933 + // 174545740275468 + + const auto x2 = x * x; + + const soft_double top = ((((((( + INT64_C(45053024618672)) + * x2 - INT64_C(3218334247465525)) + * x2 + INT64_C(40839234741969911)) + * x2 - INT64_C(190922593544635779)) + * x2 + INT64_C(402271633106633823)) + * x2 - INT64_C(388690947968573359)) + * x2 + INT64_C(140095773199074572)); + + const soft_double bot = ((((((( + INT64_C(174545740275468)) + * x2 - INT64_C(6321063389564933)) + * x2 + INT64_C(60946917703998365)) + * x2 - INT64_C(243013488210192408)) + * x2 + INT64_C(460437824033661973)) + * x2 - INT64_C(412040243501752455)) + * x2 + INT64_C(140095773199074572)); + + return (x * top) / bot; + } + + constexpr auto atan_pade(soft_double x) -> soft_double // NOLINT(performance-unnecessary-value-param) + { + // Usa a Pade approximation of atan(x). + // Then simplify, extract the coefficients of numerator and denominator. + + // PadeApproximant[ArcTan[x], {x, 0, {10, 10}}] + // FullSimplify[%] + // CoefficientList[Numerator[Out[2]] / (11 x), x^2] + // CoefficientList[Denominator[Out[2]], x^2] + + // Numerator: + // (11 * x) times: + // 1322685, 2691780, 1800162, 437580, 27985 + + // Denominator: + // 14549535, 34459425, 28378350, 9459450, 1091475, 19845 + + const auto x2 = x * x; + + const soft_double top = ((((( + UINT32_C(27985)) + * x2 + UINT32_C(437580)) + * x2 + UINT32_C(1800162)) + * x2 + UINT32_C(2691780)) + * x2 + UINT32_C(1322685)); + + const soft_double bot = (((((( + UINT32_C(19845)) + * x2 + UINT32_C(1091475)) + * x2 + UINT32_C(9459450)) + * x2 + UINT32_C(28378350)) + * x2 + UINT32_C(34459425)) + * x2 + UINT32_C(14549535)); + + return ((x * static_cast(INT8_C(11))) * top) / bot; + } + } // namespace detail constexpr auto sin(soft_double x) -> soft_double // NOLINT(misc-no-recursion) @@ -2607,6 +2696,158 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. return c; } + constexpr auto tan(soft_double x) -> soft_double // NOLINT(performance-unnecessary-value-param) + { + return sin(x) / cos(x); + } + + constexpr auto asin(soft_double x) -> soft_double // NOLINT(misc-no-recursion,performance-unnecessary-value-param) + { + soft_double result { }; + + if(x < static_cast(INT8_C(0))) + { + result = -asin(-x); + } + else if(x > static_cast(INT8_C(0))) + { + if(x > static_cast(INT8_C(1))) + { + result = soft_double::my_value_quiet_NaN(); + } + else if(x < static_cast(INT8_C(1))) + { + if(x < soft_double::my_value_half()) + { + result = detail::asin_pade(x); + } + else + { + result = soft_double::my_value_pi_half() - (detail::asin_pade(sqrt((soft_double::my_value_one() - x) / 2)) * 2); + } + } + else + { + result = soft_double::my_value_pi_half(); + } + } + else + { + // x == 0 and result = 0. + } + + return result; + } + + constexpr auto acos(soft_double x) -> soft_double // NOLINT(performance-unnecessary-value-param) + { + soft_double result { }; + + if(x < -soft_double::my_value_one()) + { + result = soft_double::my_value_quiet_NaN(); + } + else if(x > -soft_double::my_value_one()) + { + const auto absx = fabs(x); + + if(x > soft_double::my_value_one()) + { + result = soft_double::my_value_quiet_NaN(); + } + else if(x < soft_double::my_value_one()) + { + if(x < -soft_double::my_value_half()) + { + result = soft_double::my_value_pi() - 2 * detail::asin_pade(sqrt((1 - absx) / 2)); + } + else if(x < soft_double::my_value_zero()) + { + result = soft_double::my_value_pi_half() + detail::asin_pade(absx); + } + else if((x > soft_double::my_value_zero()) && (x < soft_double::my_value_half())) + { + result = soft_double::my_value_pi_half() - detail::asin_pade(x); + } + else if(x >= soft_double::my_value_half()) + { + result = 2 * detail::asin_pade(sqrt((1 - x) / 2)); + } + else + { + result = soft_double::my_value_pi_half(); + } + } + else + { + // x == 1 and result = zero. + result = soft_double::my_value_zero(); + } + } + else + { + // x == -1 and result = pi. + result = soft_double::my_value_pi(); + } + + return result; + } + + constexpr auto atan(soft_double x) -> soft_double // NOLINT(misc-no-recursion,performance-unnecessary-value-param) + { + soft_double result { }; + + if(x < soft_double::my_value_zero()) + { + result = -atan(-x); + } + else if(x > soft_double::my_value_zero()) + { + if((isinf)(x)) + { + result = soft_double::my_value_pi_half(); + } + else + { + if(x > soft_double::my_value_one()) + { + result = soft_double::my_value_pi_half() - atan(soft_double::my_value_one() / x); + } + else if(x < soft_double::my_value_one()) + { + // The algorithm for arctangent is based on Chapter 11, page 194 + // of Cody and Waite, Software Manual for the Elementary Functions, + // Prentice Hall, 1980. + + constexpr soft_double sqrt_three (static_cast(UINT64_C(0x3FFBB67AE8584CAA)), detail::nothing()); + constexpr soft_double two_minus_sqrt_three(static_cast(UINT64_C(0x3FD126145E9ECD56)), detail::nothing()); + + if(x > two_minus_sqrt_three) + { + const soft_double f { ((x * sqrt_three) - soft_double::my_value_one()) / (sqrt_three + x) }; + + result = (soft_double::my_value_pi() / static_cast(INT8_C(6))) + detail::atan_pade(f); + } + else + { + result = detail::atan_pade(x); + } + } + else + { + // x == 1 and result = pi/4. + result = soft_double::my_value_pi_half() / 2; + } + } + } + else + { + // x == 0 and result = 0. + } + + return result; + } + constexpr auto floor(soft_double x) -> soft_double // NOLINT(performance-unnecessary-value-param) { auto result = soft_double { }; @@ -2781,11 +3022,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. return exp(a * log(x)); // NOLINT(performance-unnecessary-value-param) } - constexpr auto tan(soft_double x) -> soft_double // NOLINT(performance-unnecessary-value-param) - { - return sin(x) / cos(x); - } - constexpr auto sinh(soft_double x) -> soft_double // NOLINT(performance-unnecessary-value-param) { const soft_double ep = exp(x); // NOLINT(performance-unnecessary-value-param) diff --git a/math/softfloat/soft_double_decwide_t_detail_fft_bindings.h b/math/softfloat/soft_double_decwide_t_detail_fft_bindings.h deleted file mode 100644 index 92f3a49..0000000 --- a/math/softfloat/soft_double_decwide_t_detail_fft_bindings.h +++ /dev/null @@ -1,130 +0,0 @@ -/////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020 - 2023. // -// Distributed under the Boost Software License, // -// Version 1.0. (See accompanying file LICENSE_1_0.txt // -// or copy at http://www.boost.org/LICENSE_1_0.txt) // -/////////////////////////////////////////////////////////////////// - -#ifndef SOFT_DOUBLE_DECWIDE_T_DETAIL_FFT_BINDINGS_2021_04_02_H // NOLINT(llvm-header-guard,-warnings-as-errors) - #define SOFT_DOUBLE_DECWIDE_T_DETAIL_FFT_BINDINGS_2021_04_02_H - - #include - - #include - - WIDE_DECIMAL_NAMESPACE_BEGIN - - #if(__cplusplus >= 201703L) - namespace math::wide_decimal::detail::fft { - #else - namespace math { namespace wide_decimal { namespace detail { namespace fft { // NOLINT(modernize-concat-nested-namespaces) - #endif - - template - constexpr auto template_one() -> float_type; - - template - constexpr auto template_half() -> float_type; - - template - constexpr auto template_fast_div_by_two(float_type) -> float_type; // NOLINT(readability-named-parameter,hicpp-named-parameter) - - template - constexpr auto template_sin_order_1(const std::uint32_t) -> float_type; // NOLINT(readability-named-parameter,hicpp-named-parameter,readability-avoid-const-params-in-decls) - - template<> - constexpr auto template_half() -> math::softfloat::float64_t - { - return math::softfloat::float64_t { static_cast(UINT64_C(0X3FE0000000000000)), math::softfloat::detail::nothing() }; - } - - template<> - constexpr auto template_one() -> math::softfloat::float64_t - { - return math::softfloat::float64_t { static_cast(UINT64_C(0X3FF0000000000000)), math::softfloat::detail::nothing() }; - } - - template<> - constexpr auto template_fast_div_by_two(math::softfloat::float64_t a) -> math::softfloat::float64_t // NOLINT(performance-unnecessary-value-param) - { - return - math::softfloat::float64_t - { - static_cast - ( - math::softfloat::float64_t::get_rep(a) - & static_cast - ( - ~static_cast(static_cast(UINT16_C(0x7FF)) << static_cast(UINT8_C(52))) - ) - ) - | static_cast - ( - static_cast - ( - math::softfloat::float64_t::get_rep(a) - & static_cast(UINT16_C(0x7FF)) << static_cast(UINT8_C(52)) - ) - - - static_cast - ( - static_cast(UINT8_C(1)) << static_cast(UINT8_C(52)) - ) - ), - math::softfloat::detail::nothing() - }; - } - - template<> - constexpr auto template_sin_order_1(const std::uint32_t num_points) -> math::softfloat::float64_t // NOLINT(readability-function-cognitive-complexity) - { - // Table[N[Sin[Pi / (2^n)], 41], {n, 1, 31, 1}] - // Mathematica command: Table[N[Sin[Pi / (2^n)], 41], {n, 1, 31, 1}] - return - (num_points == static_cast(UINT8_C(2))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3FF0000000000000)), math::softfloat::detail::nothing()) : // Pi / 2 : as uint64_t --> UINT64_C(0x3FF0000000000000) - (num_points == static_cast(UINT8_C(4))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3FE6A09E667F3BCD)), math::softfloat::detail::nothing()) : // Pi / 4 : as uint64_t --> UINT64_C(0x3FE6A09E667F3BCD) - (num_points == static_cast(UINT8_C(8))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3FD87DE2A6AEA963)), math::softfloat::detail::nothing()) : // Pi / 8 : as uint64_t --> UINT64_C(0x3FD87DE2A6AEA963) - (num_points == static_cast(UINT8_C(16))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3FC8F8B83C69A60B)), math::softfloat::detail::nothing()) : // Pi / 16 : as uint64_t --> UINT64_C(0x3FC8F8B83C69A60B) - (num_points == static_cast(UINT8_C(32))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3FB917A6BC29B42C)), math::softfloat::detail::nothing()) : // Pi / 32 : as uint64_t --> UINT64_C(0x3FB917A6BC29B42C) - (num_points == static_cast(UINT8_C(64))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3FA91F65F10DD814)), math::softfloat::detail::nothing()) : // Pi / 64 : as uint64_t --> UINT64_C(0x3FA91F65F10DD814) - (num_points == static_cast(UINT8_C(128))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F992155F7A3667E)), math::softfloat::detail::nothing()) : // Pi / 128 : as uint64_t --> UINT64_C(0x3F992155F7A3667E) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C( 8)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F8921D1FCDEC784)), math::softfloat::detail::nothing()) : // Pi / 2^8 : as uint64_t --> UINT64_C(0x3F8921D1FCDEC784) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C( 9)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F7921F0FE670071)), math::softfloat::detail::nothing()) : // Pi / 2^9 : as uint64_t --> UINT64_C(0x3F7921F0FE670071) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(10)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F6921F8BECCA4BA)), math::softfloat::detail::nothing()) : // Pi / 2^10 : as uint64_t --> UINT64_C(0x3F6921F8BECCA4BA) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(11)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F5921FAAEE6472E)), math::softfloat::detail::nothing()) : // Pi / 2^11 : as uint64_t --> UINT64_C(0x3F5921FAAEE6472E) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(12)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F4921FB2AECB360)), math::softfloat::detail::nothing()) : // Pi / 2^12 : as uint64_t --> UINT64_C(0x3F4921FB2AECB360) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(13)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F3921FB49EE4EA6)), math::softfloat::detail::nothing()) : // Pi / 2^13 : as uint64_t --> UINT64_C(0x3F3921FB49EE4EA6) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(14)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F2921FB51AEB57C)), math::softfloat::detail::nothing()) : // Pi / 2^14 : as uint64_t --> UINT64_C(0x3F2921FB51AEB57C) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(15)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F1921FB539ECF31)), math::softfloat::detail::nothing()) : // Pi / 2^15 : as uint64_t --> UINT64_C(0x3F1921FB539ECF31) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(16)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3F0921FB541AD59E)), math::softfloat::detail::nothing()) : // Pi / 2^16 : as uint64_t --> UINT64_C(0x3F0921FB541AD59E) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(17)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3EF921FB5439D73A)), math::softfloat::detail::nothing()) : // Pi / 2^17 : as uint64_t --> UINT64_C(0x3EF921FB5439D73A) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(18)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3EE921FB544197A1)), math::softfloat::detail::nothing()) : // Pi / 2^18 : as uint64_t --> UINT64_C(0x3EE921FB544197A1) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(19)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3ED921FB544387BA)), math::softfloat::detail::nothing()) : // Pi / 2^19 : as uint64_t --> UINT64_C(0x3ED921FB544387BA) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(20)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3EC921FB544403C1)), math::softfloat::detail::nothing()) : // Pi / 2^20 : as uint64_t --> UINT64_C(0x3EC921FB544403C1) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(21)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3EB921FB544422C2)), math::softfloat::detail::nothing()) : // Pi / 2^21 : as uint64_t --> UINT64_C(0x3EB921FB544422C2) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(22)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3EA921FB54442A83)), math::softfloat::detail::nothing()) : // Pi / 2^22 : as uint64_t --> UINT64_C(0x3EA921FB54442A83) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(23)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E9921FB54442C73)), math::softfloat::detail::nothing()) : // Pi / 2^23 : as uint64_t --> UINT64_C(0x3E9921FB54442C73) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(24)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E8921FB54442CEF)), math::softfloat::detail::nothing()) : // Pi / 2^24 : as uint64_t --> UINT64_C(0x3E8921FB54442CEF) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(25)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E7921FB54442D0E)), math::softfloat::detail::nothing()) : // Pi / 2^25 : as uint64_t --> UINT64_C(0x3E7921FB54442D0E) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(26)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E6921FB54442D16)), math::softfloat::detail::nothing()) : // Pi / 2^26 : as uint64_t --> UINT64_C(0x3E6921FB54442D16) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(27)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E5921FB54442D18)), math::softfloat::detail::nothing()) : // Pi / 2^27 : as uint64_t --> UINT64_C(0x3E5921FB54442D18) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(28)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E4921FB54442D18)), math::softfloat::detail::nothing()) : // Pi / 2^28 : as uint64_t --> UINT64_C(0x3E4921FB54442D18) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(29)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E3921FB54442D18)), math::softfloat::detail::nothing()) : // Pi / 2^29 : as uint64_t --> UINT64_C(0x3E3921FB54442D18) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(30)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E2921FB54442D18)), math::softfloat::detail::nothing()) : // Pi / 2^30 : as uint64_t --> UINT64_C(0x3E2921FB54442D18) - (num_points == static_cast(static_cast(UINT8_C(1)) << static_cast(UINT8_C(31)))) ? math::softfloat::float64_t(static_cast(UINT64_C(0x3E1921FB54442D18)), math::softfloat::detail::nothing()) : // Pi / 2^31 : as uint64_t --> UINT64_C(0x3E1921FB54442D18) - math::softfloat::float64_t(static_cast(UINT64_C(0x0000000000000000)), math::softfloat::detail::nothing()) // Pi : as uint64_t --> UINT64_C(0x0000000000000000) - ; - } - - #if(__cplusplus >= 201703L) - } // namespace math::wide_decimal::detail::fft - #else - } // namespace fft - } // namespace detail - } // namespace wide_decimal - } // namespace math - #endif - - WIDE_DECIMAL_NAMESPACE_END - -#endif // SOFT_DOUBLE_DECWIDE_T_DETAIL_FFT_BINDINGS_2021_04_02_H diff --git a/math/softfloat/soft_double_examples.h b/math/softfloat/soft_double_examples.h index ee38181..2c536c8 100644 --- a/math/softfloat/soft_double_examples.h +++ b/math/softfloat/soft_double_examples.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020 - 2022. // +// Copyright Christopher Kormanyos 2020 - 2024. // // Distributed under the Boost Software License, // // Version 1.0. (See accompanying file LICENSE_1_0.txt // // or copy at http://www.boost.org/LICENSE_1_0.txt) // /////////////////////////////////////////////////////////////////// -#ifndef SOFT_DOUBLE_EXAMPLES_2021_04_17_H_ - #define SOFT_DOUBLE_EXAMPLES_2021_04_17_H_ +#ifndef SOFT_DOUBLE_EXAMPLES_2021_04_17_H // NOLINT(llvm-header-guard) + #define SOFT_DOUBLE_EXAMPLES_2021_04_17_H #if(__cplusplus >= 201703L) namespace math::softfloat { @@ -15,7 +15,6 @@ #endif auto example001_roots_sqrt () -> bool; - auto example002b_pi_100k () -> bool; auto example004_bessel_recur () -> bool; auto example005_polylog_series () -> bool; auto example007_catalan_series () -> bool; @@ -30,4 +29,4 @@ } // namespace math #endif -#endif // SOFT_DOUBLE_EXAMPLES_2021_04_17_H_ +#endif // SOFT_DOUBLE_EXAMPLES_2021_04_17_H diff --git a/soft_double.vcxproj b/soft_double.vcxproj index 5150bcc..cf4cf26 100644 --- a/soft_double.vcxproj +++ b/soft_double.vcxproj @@ -17,7 +17,6 @@ - true @@ -35,17 +34,9 @@ - - - - - - - - diff --git a/soft_double.vcxproj.filters b/soft_double.vcxproj.filters index a1c69b1..134d3a7 100644 --- a/soft_double.vcxproj.filters +++ b/soft_double.vcxproj.filters @@ -7,21 +7,12 @@ {c2136641-a346-436a-8917-c9e7b9219550} - - {2f085500-8a6f-4d5d-bae0-5e3113acdc53} - {27ac977c-8b32-482e-8283-0c7e2c4a1e8b} {26f72b73-0fe5-4e2f-90a0-fa3e7c444dc8} - - {bf5eae75-1bea-4964-a9c9-64c2ca5c62ec} - - - {40faca56-a6d0-4300-8339-fcc6ce62b688} - {3d779015-acbe-4b19-9668-9be66032d54a} @@ -99,9 +90,6 @@ examples - - examples - test @@ -122,48 +110,24 @@ - - math\wide_decimal - - - math\wide_decimal - util\utility util\utility - - util\memory - util\utility - - math\wide_decimal - - - math\constants - - - math\wide_decimal - test - - math\softfloat - math\softfloat math\softfloat - - math\wide_decimal - util\utility diff --git a/soft_double_vs2022.vcxproj b/soft_double_vs2022.vcxproj index 377607d..cf48add 100644 --- a/soft_double_vs2022.vcxproj +++ b/soft_double_vs2022.vcxproj @@ -1,14 +1,6 @@ - - Debug - Win32 - - - Release - Win32 - Debug x64 @@ -25,19 +17,14 @@ - - true - true true true - true - true true true @@ -47,17 +34,10 @@ - - - - - - - @@ -70,6 +50,7 @@ + @@ -80,21 +61,19 @@ - true - true true true - true - true true true + + 15.0 @@ -105,19 +84,6 @@ soft_double_vs2022 - - Application - true - v143 - NotSet - - - Application - false - v143 - true - NotSet - Application true @@ -136,12 +102,6 @@ - - - - - - @@ -149,41 +109,14 @@ - - true - $(ProjectDir)test;$(ProjectDir);$(IncludePath) - true $(ProjectDir)test;$(ProjectDir);$(IncludePath) - - false - $(ProjectDir)test;$(ProjectDir);$(IncludePath) - false $(ProjectDir)test;$(ProjectDir);$(IncludePath) - - - NotUsing - Level3 - Disabled - true - LITTLEENDIAN;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - - 4146 - stdcpp20 - - - Console - true - - NotUsing @@ -203,29 +136,6 @@ true - - - NotUsing - Level3 - MaxSpeed - true - true - true - LITTLEENDIAN;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - - 4146 - stdcpp20 - - - Console - true - true - true - - NotUsing diff --git a/soft_double_vs2022.vcxproj.filters b/soft_double_vs2022.vcxproj.filters index 94ca2d6..bf4956f 100644 --- a/soft_double_vs2022.vcxproj.filters +++ b/soft_double_vs2022.vcxproj.filters @@ -7,21 +7,12 @@ {c2136641-a346-436a-8917-c9e7b9219550} - - {2f085500-8a6f-4d5d-bae0-5e3113acdc53} - {27ac977c-8b32-482e-8283-0c7e2c4a1e8b} {26f72b73-0fe5-4e2f-90a0-fa3e7c444dc8} - - {bf5eae75-1bea-4964-a9c9-64c2ca5c62ec} - - - {40faca56-a6d0-4300-8339-fcc6ce62b688} - {3d779015-acbe-4b19-9668-9be66032d54a} @@ -38,34 +29,37 @@ {38edefac-355c-4ba3-b5ef-c810713509b8} - {1e67bce6-a687-42d8-9ddf-802e4254ec22} + {db91f26a-0abe-4bb1-99ce-e891b753ef5b} - {8cdf15d5-434b-43cd-9b9b-46b0df8d1bfb} + {e060f0e6-5117-43aa-b804-2a62f098c58d} + + + {4ec239b8-1a14-49a9-b283-c08681500bb7} - {722fa9cd-ebae-4a7a-b874-5c9d30af8b7c} + {6a78c586-06c3-4ebd-ad35-9d4723f4c488} - {b606cef0-2d18-4c74-ba61-ca6af55dc876} + {eb75e937-eb5b-42b1-85d2-1b644986239e} - {49a41488-5c16-4cf5-923d-e04afdaa6fd0} + {c2d9b846-64a7-4472-9d93-fcfd30ca6e90} - {6efdbd14-e570-44ea-a87a-a13d587a6b87} + {5d2e90e0-9f02-4228-ab6e-8f8048ec9fa4} - {4df70ca7-f50b-4b5c-8811-09bb93ee5286} + {516b59e9-28a5-4421-b041-7d4a2baa31dd} - {b685cfc2-d8a0-4c4f-89c2-a1ddc7681648} + {6680c129-d68c-45b9-8210-7fe7c2a18318} - {b78f9e2a-9b15-4c19-ae9d-fe91d2218d0d} + {97e94093-f5da-43a8-a6fe-5e4e30eb5b8f} - {cfac23d0-f0e3-48d8-bc1c-26a85b412610} + {71ebaa8b-8798-4168-b374-ab35e94b6e3c} @@ -96,9 +90,6 @@ examples - - examples - test @@ -111,41 +102,23 @@ examples - - test - target\micros\stm32f429\make\single + + test + - - math\wide_decimal - - - math\wide_decimal - util\utility util\utility - - util\memory - util\utility - - math\wide_decimal - - - math\constants - - - math\wide_decimal - test @@ -158,9 +131,6 @@ math\softfloat - - math\wide_decimal - util\utility @@ -179,14 +149,21 @@ _doc + + .tidy\make + .tidy\make .tidy\make - - .tidy\make + + .github\toolchains + + + + .github\workflows .gcov\make @@ -198,13 +175,9 @@ .gcov\make - .github\workflows - - .github\workflows - target\build @@ -213,6 +186,12 @@ + + examples + + + test + diff --git a/test/test.cpp b/test/test.cpp index f30e838..0f97030 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2012 - 2023. // +// Copyright Christopher Kormanyos 2012 - 2024. // // Distributed under the Boost Software License, // // Version 1.0. (See accompanying file LICENSE_1_0.txt // // or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -13,12 +13,8 @@ // cd /mnt/c/Users/User/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/soft_double -// Build locally for test on Ubuntu (WSL). -// g++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++14 -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe -// clang++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++20 -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe - -// Build locally for test on Ubuntu (WSL) on g++-10 with C++2a. -// g++-10 -finline-functions -march=native -mtune=native -O3 -Wall -Wextra --Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++2a -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe +// Build locally for test on g++ with C++20. +// g++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra --Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++20 -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe // cd .tidy/make // make prepare -f make_tidy_01_generic.gmk @@ -29,8 +25,8 @@ // make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_CC=g++ // cd /mnt/c/Users/User/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/soft_double -// PATH=/home/chris/local/coverity/cov-analysis-linux64-2021.12.1/bin:$PATH -// cov-build --dir cov-int g++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++14 -I. examples/example001_roots_sqrt.cpp examples/example002b_pi_100k.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe +// PATH=/home/chris/coverity/cov-analysis-linux64-2023.6.2/bin:$PATH +// cov-build --dir cov-int g++ -finline-functions -march=native -mtune=native -O3 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wshadow -Wundef -Wunused-parameter -Wuninitialized -Wunreachable-code -Winit-self -Wzero-as-null-pointer-constant -std=c++14 -I. examples/example001_roots_sqrt.cpp examples/example004_bessel_recur.cpp examples/example005_polylog_series.cpp examples/example007_catalan_series.cpp examples/example010_hypergeometric_2f1.cpp examples/example011_trig_trapezoid_integral.cpp examples/example012_exercise_constexpr.cpp test/test.cpp test/test_soft_double.cpp test/test_soft_double_edge_cases.cpp test/test_soft_double_examples.cpp test/test_soft_double_spot_values.cpp -o soft_double.exe // tar caf soft_double.bz2 cov-int extern auto test_soft_double () -> bool; diff --git a/test/test_soft_double.cpp b/test/test_soft_double.cpp index 7ba6fbb..5f38e3f 100644 --- a/test/test_soft_double.cpp +++ b/test/test_soft_double.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2012 - 2023. // +// Copyright Christopher Kormanyos 2012 - 2024. // // Distributed under the Boost Software License, // // Version 1.0. (See accompanying file LICENSE_1_0.txt // // or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -71,8 +71,8 @@ std::uniform_int_distribution dst_exp (UINT32_C(0), std::uniform_int_distribution dst_sign (UINT32_C(0), UINT32_C(1)); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables,cert-err58-cpp) auto get_sf_float64_t_and_double(math::softfloat::float64_t& x1, // NOLINT(google-runtime-references,readability-function-cognitive-complexity) - double& d1, // NOLINT(google-runtime-references) - const bool is_positive = false) -> void + double& d1, // NOLINT(google-runtime-references) + const bool is_positive = false) -> void { for(;;) { @@ -419,13 +419,19 @@ auto test_sin() -> bool if(i == 0) { - result_is_ok &= s_x.crepresentation() == 0U; + const auto result_sin_zero_is_ok = (s_x.crepresentation() == 0U); + + result_is_ok = (result_sin_zero_is_ok && result_is_ok); } else { - const double closeness = std::fabs(1.0 - std::fabs(static_cast(s_x) / s_d)); + using std::fabs; + + const auto closeness = fabs(1.0 - (static_cast(s_x) / s_d)); + + const auto result_sin_is_ok = (closeness < std::numeric_limits::epsilon() * 50.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) - result_is_ok &= (closeness < std::numeric_limits::epsilon() * 50.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + result_is_ok = (result_sin_is_ok && result_is_ok); } } @@ -454,6 +460,295 @@ auto test_cos() -> bool return result_is_ok; } +auto test_tan() -> bool +{ + bool result_is_ok = true; + + for(int i = 0; i < 1501; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x = math::softfloat::float64_t(i) / 1000; + const auto d = static_cast(x); + + using std::tan; + + const math::softfloat::float64_t t_x = tan(x); + const double t_d = tan(d); + + if(i == 0) + { + const auto result_tan_zero_is_ok = (t_x.crepresentation() == 0U); + + result_is_ok = (result_tan_zero_is_ok && result_is_ok); + } + else + { + using std::fabs; + + const auto closeness = fabs(1.0 - (static_cast(t_x) / t_d)); + + const auto result_tan_is_ok = (closeness < std::numeric_limits::epsilon() * 128.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + result_is_ok = (result_tan_is_ok && result_is_ok); + } + } + + return result_is_ok; +} + +auto test_asin() -> bool +{ + bool result_is_ok = true; + + for(int i = 0; i < 100; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x = math::softfloat::float64_t(i) / 100; // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + const auto d = static_cast(x); + + using std::asin; + + const math::softfloat::float64_t as_x = asin(x); + const double as_d = asin(d); + + if(i == 0) + { + const auto result_asin_zero_is_ok = (as_x.crepresentation() == 0U); + + result_is_ok = (result_asin_zero_is_ok && result_is_ok); + } + else + { + const double closeness = std::fabs(1.0 - (static_cast(as_x) / as_d)); + + const auto result_asin_is_ok = (closeness < std::numeric_limits::epsilon() * 32.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + result_is_ok = (result_asin_is_ok && result_is_ok); + } + } + + { + const math::softfloat::float64_t x = math::softfloat::float64_t(-33) / 100; + const auto d = static_cast(x); + + using std::asin; + + const math::softfloat::float64_t as_x = asin(x); + const double as_d = asin(d); + + const double closeness = std::fabs(1.0 - (static_cast(as_x) / as_d)); + + const auto result_asin_is_ok = ((as_x < 0) && (closeness < std::numeric_limits::epsilon() * 32.0)); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + result_is_ok = (result_asin_is_ok && result_is_ok); + } + + for(int i = 121; i < 124; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x = math::softfloat::float64_t(i) / 100; // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + const math::softfloat::float64_t as_x = asin(x); + + const auto result_asin_is_ok = isnan(as_x); + + result_is_ok = (result_asin_is_ok && result_is_ok); + } + + { + std::mt19937 eng(static_cast(UINT8_C(42))); // NOLINT(cert-msc32-c,cert-msc51-cpp) + + std::uniform_int_distribution dist_one(1, 1); + + for(int i = 0; i < 3; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x_one_pos = math::softfloat::float64_t(+1) * dist_one(eng); + const math::softfloat::float64_t x_one_neg = math::softfloat::float64_t(-1) * dist_one(eng); + + using std::asin; + + const math::softfloat::float64_t asin_one_pos = asin(x_one_pos); + const math::softfloat::float64_t asin_one_neg = asin(x_one_neg); + + const auto result_asin_one_pos_neg_is_ok = ( (+asin_one_pos == math::softfloat::float64_t::my_value_pi_half()) + && (-asin_one_neg == math::softfloat::float64_t::my_value_pi_half())); + + result_is_ok = (result_asin_one_pos_neg_is_ok && result_is_ok); + } + } + + return result_is_ok; +} + +auto test_acos() -> bool +{ + bool result_is_ok = true; + + for(int i = 0; i < 100; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x = math::softfloat::float64_t(i) / 100; // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + const auto d = static_cast(x); + + using std::acos; + + const math::softfloat::float64_t ac_x = acos(x); + const double ac_d = acos(d); + + if(i == 0) + { + const auto result_acos_zero_is_ok = (ac_x == math::softfloat::float64_t::my_value_pi_half()); + + result_is_ok = (result_acos_zero_is_ok && result_is_ok); + } + else + { + const double closeness = std::fabs(1.0 - (static_cast(ac_x) / ac_d)); + + const auto result_acos_is_ok = (closeness < std::numeric_limits::epsilon() * 64.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + result_is_ok = (result_acos_is_ok && result_is_ok); + } + } + + { + const math::softfloat::float64_t x = math::softfloat::float64_t(-33) / 100; + const auto d = static_cast(x); + + using std::acos; + + const math::softfloat::float64_t ac_x = acos(x); + const double ac_d = acos(d); + + const double closeness = std::fabs(1.0 - (static_cast(ac_x) / ac_d)); + + const auto result_acos_is_ok = (closeness < std::numeric_limits::epsilon() * 64.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + result_is_ok = (result_acos_is_ok && result_is_ok); + } + + { + const math::softfloat::float64_t x = math::softfloat::float64_t(-67) / 100; + const auto d = static_cast(x); + + using std::acos; + + const math::softfloat::float64_t ac_x = acos(x); + const double ac_d = acos(d); + + const double closeness = std::fabs(1.0 - (static_cast(ac_x) / ac_d)); + + const auto result_acos_is_ok = (closeness < std::numeric_limits::epsilon() * 64.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + result_is_ok = (result_acos_is_ok && result_is_ok); + } + + for(int i = 121; i < 124; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x = math::softfloat::float64_t(i) / 100; // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + const math::softfloat::float64_t ac_x = acos(x); + + const auto result_acos_is_ok = isnan(ac_x); + + result_is_ok = (result_acos_is_ok && result_is_ok); + } + + { + std::mt19937 eng(static_cast(UINT8_C(42))); // NOLINT(cert-msc32-c,cert-msc51-cpp) + + std::uniform_int_distribution dist_one(1, 1); + + for(int i = 0; i < 3; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x_one_pos = math::softfloat::float64_t(+1) * dist_one(eng); + const math::softfloat::float64_t x_one_neg = math::softfloat::float64_t(-1) * dist_one(eng); + + using std::acos; + + const math::softfloat::float64_t acos_one_pos = acos(x_one_pos); + const math::softfloat::float64_t acos_one_neg = acos(x_one_neg); + + const auto result_acos_one_pos_neg_is_ok = ( (acos_one_pos == math::softfloat::float64_t::my_value_zero()) + && (acos_one_neg == math::softfloat::float64_t::my_value_pi())); + + result_is_ok = (result_acos_one_pos_neg_is_ok && result_is_ok); + } + } + + return result_is_ok; +} + +auto test_atan() -> bool +{ + bool result_is_ok = true; + + for(int i = -73; i < 256; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x = math::softfloat::float64_t(i) / 10; // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + const auto d = static_cast(x); + + using std::atan; + + const math::softfloat::float64_t at_x = atan(x); + const double at_d = atan(d); + + if(i == 0) + { + const auto result_atan_zero_is_ok = (at_x == math::softfloat::float64_t::my_value_zero()); + + result_is_ok = (result_atan_zero_is_ok && result_is_ok); + } + else + { + const double closeness = std::fabs(1.0 - (static_cast(at_x) / at_d)); + + const auto result_atan_is_ok = (closeness < std::numeric_limits::epsilon() * 64.0); // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + + result_is_ok = (result_atan_is_ok && result_is_ok); + } + } + + { + std::mt19937 eng(static_cast(UINT8_C(42))); // NOLINT(cert-msc32-c,cert-msc51-cpp) + + std::uniform_int_distribution dist_one(1, 1); + + for(int i = 0; i < 3; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x_one_pos = math::softfloat::float64_t(+1) * dist_one(eng); + const math::softfloat::float64_t x_one_neg = math::softfloat::float64_t(-1) * dist_one(eng); + + using std::atan; + + const math::softfloat::float64_t atan_one_pos = atan(x_one_pos); + const math::softfloat::float64_t atan_one_neg = atan(x_one_neg); + + const auto result_atan_one_pos_neg_is_ok = ( (+atan_one_pos == math::softfloat::float64_t::my_value_pi_half() / 2) + && (-atan_one_neg == math::softfloat::float64_t::my_value_pi_half() / 2)); + + result_is_ok = (result_atan_one_pos_neg_is_ok && result_is_ok); + } + } + + { + std::mt19937 eng(static_cast(UINT8_C(42))); // NOLINT(cert-msc32-c,cert-msc51-cpp) + + std::uniform_int_distribution dist_one(1, 1); + + for(int i = 0; i < 3; ++i) // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + { + const math::softfloat::float64_t x_inf = math::softfloat::float64_t::my_value_infinity() * dist_one(eng); + + using std::atan; + + const math::softfloat::float64_t atan_inf = atan(x_inf); + + const auto result_acos_inf_is_ok = (atan_inf == math::softfloat::float64_t::my_value_pi_half()); + + result_is_ok = (result_acos_inf_is_ok && result_is_ok); + } + } + + return result_is_ok; +} + auto test_floor(const std::uint32_t n) -> bool { bool result_is_ok = true; @@ -751,6 +1046,10 @@ auto test_soft_double() -> bool std::cout << "testing log____... "; const auto result_log____is_ok = test_log ( ); std::cout << std::boolalpha << result_log____is_ok << std::endl; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) std::cout << "testing sin____... "; const auto result_sin____is_ok = test_sin ( ); std::cout << std::boolalpha << result_sin____is_ok << std::endl; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) std::cout << "testing cos____... "; const auto result_cos____is_ok = test_cos ( ); std::cout << std::boolalpha << result_cos____is_ok << std::endl; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) + std::cout << "testing tan____... "; const auto result_tan____is_ok = test_tan ( ); std::cout << std::boolalpha << result_tan____is_ok << std::endl; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) + std::cout << "testing asin___... "; const auto result_asin___is_ok = test_asin ( ); std::cout << std::boolalpha << result_asin___is_ok << std::endl; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) + std::cout << "testing acos___... "; const auto result_acos___is_ok = test_acos ( ); std::cout << std::boolalpha << result_acos___is_ok << std::endl; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) + std::cout << "testing atan___... "; const auto result_atan___is_ok = test_atan ( ); std::cout << std::boolalpha << result_atan___is_ok << std::endl; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) local::eng32.seed(::util::util_pseudorandom_time_point_seed::value()); local::eng64.seed(::util::util_pseudorandom_time_point_seed::value()); @@ -798,6 +1097,10 @@ auto test_soft_double() -> bool && result_log____is_ok && result_sin____is_ok && result_cos____is_ok + && result_tan____is_ok + && result_asin___is_ok + && result_acos___is_ok + && result_atan___is_ok && result_floor__is_ok && result_ceil___is_ok && result_add____is_ok diff --git a/test/test_soft_double_examples.cpp b/test/test_soft_double_examples.cpp index ccfab81..09dc48f 100644 --- a/test/test_soft_double_examples.cpp +++ b/test/test_soft_double_examples.cpp @@ -17,7 +17,6 @@ auto test_soft_double_examples() -> bool std::cout << "Start test_soft_double_examples()" << std::endl; result_examples_is_ok &= math::softfloat::example001_roots_sqrt (); std::cout << "example001_roots_sqrt : " << std::boolalpha << result_examples_is_ok << std::endl; - result_examples_is_ok &= math::softfloat::example002b_pi_100k (); std::cout << "example002b_pi_100k : " << std::boolalpha << result_examples_is_ok << std::endl; result_examples_is_ok &= math::softfloat::example004_bessel_recur (); std::cout << "example004_bessel_recur : " << std::boolalpha << result_examples_is_ok << std::endl; result_examples_is_ok &= math::softfloat::example005_polylog_series (); std::cout << "example005_polylog_series : " << std::boolalpha << result_examples_is_ok << std::endl; result_examples_is_ok &= math::softfloat::example007_catalan_series (); std::cout << "example007_catalan_series : " << std::boolalpha << result_examples_is_ok << std::endl; diff --git a/test/test_soft_double_examples.h b/test/test_soft_double_examples.h index a396e0b..a4b5b15 100644 --- a/test/test_soft_double_examples.h +++ b/test/test_soft_double_examples.h @@ -1,13 +1,13 @@ /////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020 - 2022. // +// Copyright Christopher Kormanyos 2020 - 2024. // // Distributed under the Boost Software License, // // Version 1.0. (See accompanying file LICENSE_1_0.txt // // or copy at http://www.boost.org/LICENSE_1_0.txt) // /////////////////////////////////////////////////////////////////// -#ifndef TEST_SOFT_DOUBLE_EXAMPLES_2021_04_17_H_ - #define TEST_SOFT_DOUBLE_EXAMPLES_2021_04_17_H_ +#ifndef TEST_SOFT_DOUBLE_EXAMPLES_2021_04_17_H // NOLINT(llvm-header-guard) + #define TEST_SOFT_DOUBLE_EXAMPLES_2021_04_17_H auto test_soft_double_examples() -> bool; -#endif // TEST_SOFT_DOUBLE_EXAMPLES_2021_04_17_H_ +#endif // TEST_SOFT_DOUBLE_EXAMPLES_2021_04_17_H diff --git a/util/memory/util_n_slot_array_allocator.h b/util/memory/util_n_slot_array_allocator.h deleted file mode 100644 index ae3c4f6..0000000 --- a/util/memory/util_n_slot_array_allocator.h +++ /dev/null @@ -1,192 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020 - 2022. -// Distributed under the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt -// or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef UTIL_N_SLOT_ARRAY_ALLOCATOR_2020_10_25_H // NOLINT(llvm-header-guard) - #define UTIL_N_SLOT_ARRAY_ALLOCATOR_2020_10_25_H - - #include - #include - #include - #include - - namespace util { - - // Forward declaration of n_slot_array_allocator template. - template - class n_slot_array_allocator; - - // Template partial specialization of n_slot_array_allocator template for void. - template - class n_slot_array_allocator - { - public: - using value_type = void; - using pointer = value_type*; - using const_pointer = const value_type*; - - template - struct rebind - { - using other = n_slot_array_allocator; - }; - }; - - template - class n_slot_array_allocator // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) - { - private: - static constexpr std::uint_fast32_t slot_width = SlotWidth; - static constexpr std::size_t slot_count = SlotCount; - - using slot_array_type = std::array; - using slot_array_memory_type = std::array; - using slot_array_flags_type = std::array; - - public: - using size_type = std::size_t; - using value_type = typename slot_array_type::value_type; - using pointer = value_type*; - using const_pointer = const value_type*; - using reference = value_type&; - using const_reference = const value_type&; - - constexpr n_slot_array_allocator() = default; // LCOV_EXCL_LINE - - constexpr n_slot_array_allocator(const n_slot_array_allocator&) = default; // LCOV_EXCL_LINE - - template - struct rebind - { - using other = n_slot_array_allocator; - }; - - constexpr auto max_size() const noexcept -> size_type { return slot_count; } - - constexpr auto address( reference x) const -> pointer { return &x; } - constexpr auto address(const_reference x) const -> const_pointer { return &x; } - - auto allocate - ( - size_type count, - typename n_slot_array_allocator::const_pointer p_hint = nullptr - ) -> pointer - { - static_cast(count); - static_cast(p_hint); - - pointer p = nullptr; - - // TBD: There is most likely significant optimization potential - // capable of being unlocked if a storage/lookup mechanism can be - // devised that uses a binary search when finding the next free slot. - - for(std::size_t i = 0U; i < slot_count; ++i) - { - if(slot_flags[i] == 0U) // NOLINT(cppcoreguidelines-pro-bounds-constant-array-index) - { - slot_flags[i] = 1U; // NOLINT(cppcoreguidelines-pro-bounds-constant-array-index) - - p = static_cast(slot_array_memory[i].data()); // NOLINT(cppcoreguidelines-pro-bounds-constant-array-index) - - if(i > slot_max_index) - { - slot_max_index = i; - - static_cast(slot_max_index); - } - - break; - } - } - - return p; - } - - auto construct(pointer p, const value_type& x) -> void - { - // The memory in the n-slot allocator already exists - // in an uninitialized form. Construction can safely - // simply set the value in the uninitialized memory. - - *p = x; - } - - auto destroy(pointer p) const -> void { static_cast(p); } // LCOV_EXCL_LINE - - auto deallocate(pointer p_slot, size_type sz) -> void - { - static_cast(sz); - - auto index = static_cast(UINT8_C(0)); - - for(auto& slot_array_memory_entry : slot_array_memory) - { - if(p_slot == static_cast(slot_array_memory_entry.data())) - { - slot_flags[index] = static_cast(UINT8_C(0)); // NOLINT(cppcoreguidelines-pro-bounds-constant-array-index) - - break; - } - - ++index; - } - } - - private: - static slot_array_memory_type slot_array_memory; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) - static slot_array_flags_type slot_flags; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) - static std::size_t slot_max_index; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) - }; - - template - typename n_slot_array_allocator::slot_array_memory_type n_slot_array_allocator::slot_array_memory; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - - template - typename n_slot_array_allocator::slot_array_flags_type n_slot_array_allocator::slot_flags; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - - template - std::size_t n_slot_array_allocator::slot_max_index; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - - // Global comparison operators (required by the standard). - template - auto operator==(const n_slot_array_allocator& left, - const n_slot_array_allocator& right) -> bool - { - static_cast(left.max_size()); - static_cast(right.max_size()); - - return true; - } - - template - auto operator!=(const n_slot_array_allocator& left, - const n_slot_array_allocator& right) -> bool - { - static_cast(left.max_size()); - static_cast(right.max_size()); - - return false; - } - - } // namespace util - -#endif // UTIL_N_SLOT_ARRAY_ALLOCATOR_2020_10_25_H diff --git a/util/utility/util_pseudorandom_time_point_seed.h b/util/utility/util_pseudorandom_time_point_seed.h index 3ecd21b..36757b3 100644 --- a/util/utility/util_pseudorandom_time_point_seed.h +++ b/util/utility/util_pseudorandom_time_point_seed.h @@ -49,7 +49,7 @@ #pragma warning(disable : 4996) #endif // Format the time in a calendar-style. - strftime(buf.data(), buf.size(), "%c", std::localtime(&now)); // NOLINT(concurrency-mt-unsafe) + strftime(buf.data(), buf.size(), "%c", std::localtime(&now)); // NOLINT(concurrency-mt-unsafe,cert-err33-c) #if defined(_MSC_VER) #pragma warning( pop ) #endif