Add AGM test

This commit is contained in:
Matt Borland 2023-05-22 13:43:32 +02:00
parent aef57135b3
commit ca31dcfe93
No known key found for this signature in database
GPG Key ID: A0144D0CA689D087
2 changed files with 38 additions and 18 deletions

View File

@ -7,9 +7,12 @@
#ifndef BOOST_MATH_SPECIAL_DAUBECHIES_SCALING_HPP
#define BOOST_MATH_SPECIAL_DAUBECHIES_SCALING_HPP
#include <cstdint>
#include <cstring>
#include <cmath>
#include <vector>
#include <array>
#include <cmath>
#include <thread>
#include <future>
#include <iostream>
@ -208,12 +211,13 @@ public:
inline Real prime(Real x) const
{
using std::floor;
Real y = x*s_;
Real k = floor(y);
int64_t kk = static_cast<int64_t>(k);
Real t = y - k;
return (1-t)*dydx_[kk] + t*dydx_[kk+1];
return static_cast<Real>((Real(1)-t)*dydx_[kk] + t*dydx_[kk+1]);
}
int64_t bytes() const
@ -372,13 +376,13 @@ public:
}
else if (std::is_same_v<Real, double>)
{
// p= 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
std::array<int, 20> r{ -1, -1, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18, 18, 18, 18 };
grid_refinements = r[p];
// p= 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
std::array<int, 20> r{ -1, -1, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18, 18, 18, 18 };
grid_refinements = r[p];
}
else
{
grid_refinements = 21;
grid_refinements = 21;
}
}
@ -423,17 +427,17 @@ public:
vector_type data(y.size());
for (size_t i = 0; i < y.size(); ++i)
{
data[i][0] = y[i];
data[i][1] = dydx[i];
if constexpr (p >= 6)
data[i][2] = d2ydx2[i];
if constexpr (p >= 10)
data[i][3] = d3ydx3[i];
data[i][0] = y[i];
data[i][1] = dydx[i];
if constexpr (p >= 6)
data[i][2] = d2ydx2[i];
if constexpr (p >= 10)
data[i][3] = d3ydx3[i];
}
if constexpr (p <= 3)
m_interpolator = std::make_shared<interpolator_type>(std::move(data), grid_refinements, Real(0));
m_interpolator = std::make_shared<interpolator_type>(std::move(data), grid_refinements, Real(0));
else
m_interpolator = std::make_shared<interpolator_type>(std::move(data), Real(0), Real(1) / (1 << grid_refinements));
m_interpolator = std::make_shared<interpolator_type>(std::move(data), Real(0), Real(1) / (1 << grid_refinements));
}
else
m_interpolator = std::make_shared<detail::null_interpolator>();
@ -452,7 +456,7 @@ public:
inline Real prime(Real x) const
{
static_assert(p > 2, "The 3-vanishing moment Daubechies scaling function is the first which is continuously differentiable.");
if (x <= 0 || x >= 2*p-1)
if (x <= Real(0) || x >= 2*p-1)
{
return 0;
}

View File

@ -13,6 +13,11 @@
#include <boost/math/tools/test_value.hpp>
#include <boost/core/demangle.hpp>
#include <boost/math/tools/agm.hpp>
#if __has_include(<stdfloat>)
# include <stdfloat>
#endif
#ifdef BOOST_HAS_FLOAT128
#include <boost/multiprecision/float128.hpp>
using boost::multiprecision::float128;
@ -91,13 +96,24 @@ void test_scaling()
int main()
{
#ifdef __STDCPP_FLOAT32_T__
test_gauss_constant<std::float32_t>();
test_scaling<std::float32_t>();
#else
test_gauss_constant<float>();
test_gauss_constant<double>();
test_gauss_constant<long double>();
test_scaling<float>();
#endif
#ifdef __STDCPP_FLOAT64_T__
test_scaling<std::float64_t>();
test_gauss_constant<std::float64_t>();
#else
test_scaling<double>();
test_gauss_constant<double>();
#endif
test_scaling<long double>();
test_gauss_constant<long double>();
#ifdef BOOST_HAS_FLOAT128
test_gauss_constant<float128>();