From 290dde950384f76bc93a086f6c8d69a6fc014290 Mon Sep 17 00:00:00 2001 From: Christopher Mauney Date: Thu, 14 Nov 2024 15:22:51 -0700 Subject: [PATCH 1/2] more pi than pi --- test/test_span.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test_span.cpp b/test/test_span.cpp index a6f45644..c27cb76d 100644 --- a/test/test_span.cpp +++ b/test/test_span.cpp @@ -1,7 +1,7 @@ -#include "ports-of-call/span.hpp" #include "ports-of-call/portability.hpp" -#include +#include "ports-of-call/span.hpp" #include +#include // ======================================================================================== // © (or copyright) 2019-2024. Triad National Security, LLC. All rights @@ -564,19 +564,17 @@ TEST_CASE("span portability", "[PortsOfCall::span]") { constexpr const std::size_t Nb = N * sizeof(Real); constexpr const Real tol = 1.0E-8; - constexpr const Real pi = std::acos(-1); + constexpr const Real pi = 3.141592653589793238462643383279502884; constexpr Real d_gp = 2. * pi / static_cast(N); std::vector h_gp(N); - for(auto i = 0; i < N; ++i) - { + for (auto i = 0; i < N; ++i) { h_gp[i] = -pi + static_cast(i) * d_gp; } + Real *p_a = (Real *)PORTABLE_MALLOC(Nb); - Real *p_a = (Real*) PORTABLE_MALLOC(Nb); - // device span, host span span d_s(p_a, N); span h_s(h_gp); @@ -586,11 +584,13 @@ TEST_CASE("span portability", "[PortsOfCall::span]") { // integrate cos x dx over [-pi,pi] Real res_sum{0.0}; - portableReduce( "integrate", 0, N, PORTABLE_LAMBDA(const int i, Real& rsum){ rsum += (std::cos(d_s[i])*d_gp) ;}, res_sum); + portableReduce( + "integrate", 0, N, + PORTABLE_LAMBDA(const int i, Real &rsum) { rsum += (std::cos(d_s[i]) * d_gp); }, + res_sum); // require sum < tol - REQUIRE(std::abs(res_sum) < tol); - + REQUIRE(std::abs(res_sum) < tol); PORTABLE_FREE(p_a); } From eb0b4236bff4353f22bd5eba58df2c47ec64c911 Mon Sep 17 00:00:00 2001 From: Christopher Mauney Date: Thu, 14 Nov 2024 15:35:40 -0700 Subject: [PATCH 2/2] even More pi --- test/test_span.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_span.cpp b/test/test_span.cpp index c27cb76d..799a0d44 100644 --- a/test/test_span.cpp +++ b/test/test_span.cpp @@ -564,7 +564,7 @@ TEST_CASE("span portability", "[PortsOfCall::span]") { constexpr const std::size_t Nb = N * sizeof(Real); constexpr const Real tol = 1.0E-8; - constexpr const Real pi = 3.141592653589793238462643383279502884; + constexpr const Real pi = M_PI; constexpr Real d_gp = 2. * pi / static_cast(N);