2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Deal with inspect issues in test/.

This commit is contained in:
jzmaddock
2021-03-30 17:55:13 +01:00
parent 5f178548e0
commit 67aa0c1444
20 changed files with 97 additions and 45 deletions

View File

@@ -1 +1,5 @@
# Copyright 2021 Matt Borland
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
add_subdirectory(compile_test)

View File

@@ -1,3 +1,7 @@
# Copyright 2021 Matt Borland
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
file(GLOB SOURCES "*.cpp")
add_library(compile_tests ${SOURCES})
target_compile_features(compile_tests PRIVATE cxx_std_17)

View File

@@ -1,4 +1,9 @@
// Basic sanity check that header <boost/math/special_functions/ellint_1.hpp>
// Copyright Evan Miller 2020.
// Use, modification and distribution are subject to 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)
// Basic sanity check that header <boost/math/special_functions/jacobi_theta.hpp>
// #includes all the files that it needs to.
//
#include <boost/math/special_functions/jacobi_theta.hpp>

View File

@@ -53,7 +53,7 @@ void test_constant()
CHECK_ULP_CLOSE(Real(7), hermite_spline(thi), 2);
CHECK_ULP_CLOSE(Real(0), hermite_spline.prime(tlo), 2);
CHECK_ULP_CLOSE(Real(0), hermite_spline.prime(thi), 2);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
@@ -262,7 +262,7 @@ void test_cardinal_constant()
CHECK_ULP_CLOSE(Real(0), hermite_spline_aos.prime(tlo), 2);
CHECK_ULP_CLOSE(Real(0), hermite_spline_aos.prime(thi), 2);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
@@ -329,7 +329,7 @@ void test_cardinal_linear()
CHECK_ULP_CLOSE(Real(1), hermite_spline_aos.prime(tlo), 2);
CHECK_ULP_CLOSE(Real(1), hermite_spline_aos.prime(thi), 2);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
@@ -387,7 +387,7 @@ void test_cardinal_quadratic()
CHECK_ULP_CLOSE(Real(tlo), saos.prime(tlo), 3);
CHECK_ULP_CLOSE(Real(thi), saos.prime(thi), 3);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
}

View File

@@ -11,6 +11,7 @@
#include <iomanip>
#include <iostream>
#include <random>
#include <boost/assert.hpp>
#include <boost/core/demangle.hpp>
#include <boost/hana/for_each.hpp>
#include <boost/hana/ext/std/integer_sequence.hpp>
@@ -244,7 +245,7 @@ void test_dyadic_grid()
{
auto phijk = boost::math::daubechies_scaling_dyadic_grid<Real, i+2, 0>(0);
auto phik = boost::math::detail::daubechies_scaling_integer_grid<Real, i+2, 0>();
assert(phik.size() == phijk.size());
BOOST_ASSERT(phik.size() == phijk.size());
for (size_t k = 0; k < phik.size(); ++k)
{
@@ -353,15 +354,15 @@ void test_quadratures()
CHECK_ULP_CLOSE(Real(0), phi(xlo), 0);
CHECK_ULP_CLOSE(Real(0), phi(xhi), 0);
xlo = std::nextafter(xlo, std::numeric_limits<Real>::lowest());
xhi = std::nextafter(xhi, std::numeric_limits<Real>::max());
xhi = std::nextafter(xhi, (std::numeric_limits<Real>::max)());
}
xlo = a;
xhi = b;
for (int i = 0; i < samples; ++i) {
assert(abs(phi(xlo)) <= 5);
assert(abs(phi(xhi)) <= 5);
xlo = std::nextafter(xlo, std::numeric_limits<Real>::max());
BOOST_ASSERT(abs(phi(xlo)) <= 5);
BOOST_ASSERT(abs(phi(xhi)) <= 5);
xlo = std::nextafter(xlo, (std::numeric_limits<Real>::max)());
xhi = std::nextafter(xhi, std::numeric_limits<Real>::lowest());
}
@@ -392,7 +393,7 @@ void test_quadratures()
}
std::random_device rd;
Real t = static_cast<Real>(rd())/static_cast<Real>(rd.max());
Real t = static_cast<Real>(rd())/static_cast<Real>((rd.max)());
Real S = phi(t);
Real dS = phi.prime(t);
while (t < b)
@@ -425,23 +426,23 @@ void test_quadratures()
CHECK_ULP_CLOSE(Real(0), phi(xlo), 0);
CHECK_ULP_CLOSE(Real(0), phi(xhi), 0);
if constexpr (p > 2) {
assert(abs(phi.prime(xlo)) <= 5);
assert(abs(phi.prime(xhi)) <= 5);
BOOST_ASSERT(abs(phi.prime(xlo)) <= 5);
BOOST_ASSERT(abs(phi.prime(xhi)) <= 5);
if constexpr (p > 5) {
assert(abs(phi.double_prime(xlo)) <= 5);
assert(abs(phi.double_prime(xhi)) <= 5);
BOOST_ASSERT(abs(phi.double_prime(xlo)) <= 5);
BOOST_ASSERT(abs(phi.double_prime(xhi)) <= 5);
}
}
xlo = std::nextafter(xlo, std::numeric_limits<Real>::lowest());
xhi = std::nextafter(xhi, std::numeric_limits<Real>::max());
xhi = std::nextafter(xhi, (std::numeric_limits<Real>::max)());
}
xlo = a;
xhi = b;
for (int i = 0; i < samples; ++i) {
assert(abs(phi(xlo)) <= 5);
assert(abs(phi(xhi)) <= 5);
xlo = std::nextafter(xlo, std::numeric_limits<Real>::max());
BOOST_ASSERT(abs(phi(xlo)) <= 5);
BOOST_ASSERT(abs(phi(xhi)) <= 5);
xlo = std::nextafter(xlo, (std::numeric_limits<Real>::max)());
xhi = std::nextafter(xhi, std::numeric_limits<Real>::lowest());
}
}

View File

@@ -12,6 +12,7 @@
#include <iostream>
#include <random>
#include <cmath>
#include <boost/assert.hpp>
#include <boost/core/demangle.hpp>
#include <boost/hana/for_each.hpp>
#include <boost/hana/ext/std/integer_sequence.hpp>
@@ -93,26 +94,26 @@ void test_quadratures()
}
}
xlo = std::nextafter(xlo, std::numeric_limits<Real>::lowest());
xhi = std::nextafter(xhi, std::numeric_limits<Real>::max());
xhi = std::nextafter(xhi, (std::numeric_limits<Real>::max)());
}
xlo = a;
xhi = b;
for (int i = 0; i < samples; ++i) {
std::cout << std::setprecision(std::numeric_limits<Real>::max_digits10);
assert(abs(psi(xlo)) <= 5);
assert(abs(psi(xhi)) <= 5);
BOOST_ASSERT(abs(psi(xlo)) <= 5);
BOOST_ASSERT(abs(psi(xhi)) <= 5);
if constexpr (p > 2)
{
assert(abs(psi.prime(xlo)) <= 5);
assert(abs(psi.prime(xhi)) <= 5);
BOOST_ASSERT(abs(psi.prime(xlo)) <= 5);
BOOST_ASSERT(abs(psi.prime(xhi)) <= 5);
if constexpr (p >= 6)
{
assert(abs(psi.double_prime(xlo)) <= 5);
assert(abs(psi.double_prime(xhi)) <= 5);
BOOST_ASSERT(abs(psi.double_prime(xlo)) <= 5);
BOOST_ASSERT(abs(psi.double_prime(xhi)) <= 5);
}
}
xlo = std::nextafter(xlo, std::numeric_limits<Real>::max());
xlo = std::nextafter(xlo, (std::numeric_limits<Real>::max)());
xhi = std::nextafter(xhi, std::numeric_limits<Real>::lowest());
}
}

View File

@@ -56,7 +56,7 @@ void test_well_known()
21846713216,27803071890,31804388758,32651669133};
auto a = engel.digits();
// The last digit might be off somewhat, so don't test it:
size_t n = std::min(a.size() - 1, expected.size());
size_t n = (std::min)(a.size() - 1, expected.size());
for(size_t i = 0; i < n; ++i)
{
if (!CHECK_EQUAL(expected[i], a[i]))

View File

@@ -1,3 +1,10 @@
/*
* Copyright Evan Miller, 2020
* Use, modification and distribution are subject to 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 SC_
# define SC_(x) static_cast<T>(BOOST_JOIN(x, L))
#endif

View File

@@ -1,3 +1,10 @@
/*
* Copyright Evan Miller, 2020
* Use, modification and distribution are subject to 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 SC_
# define SC_(x) static_cast<T>(BOOST_JOIN(x, L))
#endif

View File

@@ -20,7 +20,7 @@ void test_trivial()
// Validate in R:
// > v <- c(1,2)
// > Box.test(v, lag=1, "Ljung")
// Box-Ljung test
// Box-Ljung test
// data: v
// X-squared = 2, df = 1, p-value = 0.1573

View File

@@ -11,6 +11,7 @@
#include <random>
#include <boost/math/interpolators/pchip.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/assert.hpp>
#ifdef BOOST_HAS_FLOAT128
#include <boost/multiprecision/float128.hpp>
using boost::multiprecision::float128;
@@ -192,7 +193,7 @@ void test_monotonicity()
CHECK_ULP_CLOSE(y[i], s(x[i]), 2);
for (Real t = tmin; t < tmax; t += (tmax-tmin)/16) {
Real greater_val = s(t);
assert(val <= greater_val);
BOOST_ASSERT(val <= greater_val);
val = greater_val;
}
}
@@ -217,7 +218,7 @@ void test_monotonicity()
CHECK_ULP_CLOSE(y[i], s(x[i]), 2);
for (Real t = tmin; t < tmax; t += (tmax-tmin)/16) {
Real lesser_val = s(t);
assert(val >= lesser_val);
BOOST_ASSERT(val >= lesser_val);
val = lesser_val;
}
}

View File

@@ -304,7 +304,7 @@ void test_cardinal_constant()
CHECK_ULP_CLOSE(Real(0), qh_aos.prime(tlo), 2);
CHECK_ULP_CLOSE(Real(0), qh_aos.prime(thi), 2);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
}
@@ -357,7 +357,7 @@ void test_cardinal_linear()
CHECK_ULP_CLOSE(Real(1), qh_aos.prime(tlo), 2);
CHECK_ULP_CLOSE(Real(1), qh_aos.prime(thi), 128);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
}
@@ -420,7 +420,7 @@ void test_cardinal_quadratic()
CHECK_ULP_CLOSE(tlo, qh_aos.prime(tlo), 16);
CHECK_ULP_CLOSE(thi, qh_aos.prime(thi), 64);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
}

View File

@@ -25,7 +25,7 @@ void test_rsqrt()
{
std::cout << "Testing rsqrt on type " << boost::core::demangle(typeid(Real).name()) << "\n";
using std::sqrt;
Real x = std::numeric_limits<Real>::min();
Real x = (std::numeric_limits<Real>::min)();
while (x < 10000*std::numeric_limits<Real>::epsilon()) {
Real expected = 1/sqrt(x);
Real computed = rsqrt(x);
@@ -64,7 +64,7 @@ void test_rsqrt()
std::cerr << "Reciprocal square root of infinity not correctly computed.\n";
}
x = std::numeric_limits<Real>::max();
x = (std::numeric_limits<Real>::max)();
expected = 1/sqrt(x);
computed = rsqrt(x);
if (!CHECK_EQUAL(expected, computed)) {

View File

@@ -94,7 +94,7 @@ void test_constant()
CHECK_ULP_CLOSE(Real(0), csh_aos.double_prime(tlo), 2);
CHECK_ULP_CLOSE(Real(0), csh_aos.double_prime(thi), 2);
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}
@@ -195,7 +195,7 @@ void test_linear()
CHECK_MOLLIFIED_CLOSE(Real(0), csh_aos.double_prime(tlo), std::numeric_limits<Real>::epsilon());
CHECK_MOLLIFIED_CLOSE(Real(0), csh_aos.double_prime(thi), 1200*std::numeric_limits<Real>::epsilon());
tlo = boost::math::nextafter(tlo, std::numeric_limits<Real>::max());
tlo = boost::math::nextafter(tlo, (std::numeric_limits<Real>::max)());
thi = boost::math::nextafter(thi, std::numeric_limits<Real>::lowest());
}

View File

@@ -27,4 +27,4 @@ int main() {
Real expected = (7*zeta_three<Real>() - pi<Real>()*pi<Real>()*log(static_cast<Real>(4)))/16;
CHECK_ULP_CLOSE(expected, Q, 3);
return boost::math::test::report_errors();
}
}

View File

@@ -103,4 +103,4 @@ BOOST_AUTO_TEST_CASE(constexpr_check) {
// checked fibonacci can't be constexpr because of non-constexpr
// dependency in detail::log_2, detail::fib_bits_phi, detail::fib_bits_deno
}
}

View File

@@ -1,3 +1,9 @@
/*
* Copyright Evan Miller, 2020
* Use, modification and distribution are subject to 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 <pch_light.hpp>
#include <boost/math/concepts/real_concept.hpp>

View File

@@ -1,5 +1,9 @@
// Copyright John Maddock 2006.
// Copyright Evan Miller 2020
/*
* Copyright Evan Miller, 2020
* Use, modification and distribution are subject to 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)
*/
#define BOOST_TEST_MAIN
#define NOMINMAX
#include <boost/test/unit_test.hpp>
@@ -589,7 +593,7 @@ inline void test_mellin_transforms(RealType s, RealType integration_eps, RealTyp
{
if (t*t == 0.f)
return RealType(0);
if (t > sqrt(sqrt(std::numeric_limits<RealType>::max())))
if (t > sqrt(sqrt((std::numeric_limits<RealType>::max)())))
return RealType(0);
return pow(t, s-1) * jacobi_theta2tau(RealType(0), t*t);
@@ -599,7 +603,7 @@ inline void test_mellin_transforms(RealType s, RealType integration_eps, RealTyp
{
if (t*t == 0.f)
return RealType(0);
if (t > sqrt(sqrt(std::numeric_limits<RealType>::max())))
if (t > sqrt(sqrt((std::numeric_limits<RealType>::max)())))
return RealType(0);
return pow(t, s-1) * jacobi_theta3m1tau(RealType(0), t*t);
@@ -609,7 +613,7 @@ inline void test_mellin_transforms(RealType s, RealType integration_eps, RealTyp
{
if (t*t == 0.f)
return RealType(0);
if (t > sqrt(sqrt(std::numeric_limits<RealType>::max())))
if (t > sqrt(sqrt((std::numeric_limits<RealType>::max)())))
return RealType(0);
return -pow(t, s-1) * jacobi_theta4m1tau(RealType(0), t*t);

View File

@@ -1,3 +1,9 @@
/*
* Copyright John Maddock, 2020
* Use, modification and distribution are subject to 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)
*/
static const boost::array<boost::array<T, 3>, 198> factorials = {{
{ SC_(1), SC_(1), SC_(0) },
{ SC_(2), SC_(1), SC_(0) },

View File

@@ -1,3 +1,9 @@
/*
* Copyright Evan Miller, 2020
* Use, modification and distribution are subject to 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 "mp_t.hpp"
#include <boost/math/tools/test_data.hpp>