mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Rename filter computation functions to reflect the fact that multiple orders of differentiation may be computed. [CI SKIP]
This commit is contained in:
@@ -157,7 +157,7 @@ class discrete_legendre {
|
||||
};
|
||||
|
||||
template <class Real>
|
||||
std::vector<Real> interior_filter(size_t n, size_t p) {
|
||||
std::vector<Real> interior_velocity_filter(size_t n, size_t p) {
|
||||
// We could make the filter length n, as f[0] = 0,
|
||||
// but that'd make the indexing awkward when applying the filter.
|
||||
std::vector<Real> f(n + 1, 0);
|
||||
@@ -187,7 +187,7 @@ std::vector<Real> interior_filter(size_t n, size_t p) {
|
||||
}
|
||||
|
||||
template <class Real>
|
||||
std::vector<Real> boundary_filter(size_t n, size_t p, int64_t s)
|
||||
std::vector<Real> boundary_velocity_filter(size_t n, size_t p, int64_t s)
|
||||
{
|
||||
std::vector<Real> f(2 * n + 1, 0);
|
||||
auto dlp = discrete_legendre<Real>(n);
|
||||
@@ -223,7 +223,7 @@ std::vector<Real> boundary_filter(size_t n, size_t p, int64_t s)
|
||||
}
|
||||
|
||||
template <class Real>
|
||||
std::vector<Real> acceleration_boundary_filter(size_t n, size_t p, int64_t s)
|
||||
std::vector<Real> acceleration_filter(size_t n, size_t p, int64_t s)
|
||||
{
|
||||
BOOST_ASSERT_MSG(p <= 2*n, "Approximation order must be <= 2*n");
|
||||
BOOST_ASSERT_MSG(p > 2, "Approximation order must be > 2");
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
|
||||
if constexpr (std::is_same_v<Real, float> || std::is_same_v<Real, double>)
|
||||
{
|
||||
auto interior = detail::interior_filter<long double>(n, approximation_order);
|
||||
auto interior = detail::interior_velocity_filter<long double>(n, approximation_order);
|
||||
m_f.resize(interior.size());
|
||||
for (size_t j = 0; j < interior.size(); ++j)
|
||||
{
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
m_f = detail::interior_filter<Real>(n, approximation_order);
|
||||
m_f = detail::interior_velocity_filter<Real>(n, approximation_order);
|
||||
}
|
||||
|
||||
m_boundary_filters.resize(n);
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
if constexpr (std::is_same_v<Real, float> || std::is_same_v<Real, double>)
|
||||
{
|
||||
int64_t s = static_cast<int64_t>(i) - static_cast<int64_t>(n);
|
||||
auto bf = detail::boundary_filter<long double>(n, approximation_order, s);
|
||||
auto bf = detail::boundary_velocity_filter<long double>(n, approximation_order, s);
|
||||
m_boundary_filters[i].resize(bf.size());
|
||||
for (size_t j = 0; j < bf.size(); ++j)
|
||||
{
|
||||
@@ -308,7 +308,7 @@ public:
|
||||
else
|
||||
{
|
||||
int64_t s = static_cast<int64_t>(i) - static_cast<int64_t>(n);
|
||||
m_boundary_filters[i] = detail::boundary_filter<Real>(n, approximation_order, s);
|
||||
m_boundary_filters[i] = detail::boundary_velocity_filter<Real>(n, approximation_order, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
// since the resulting cost is a factor of 2, and the cost of the filters not working is hours of debugging.
|
||||
if constexpr (std::is_same_v<Real, double> || std::is_same_v<Real, float>)
|
||||
{
|
||||
auto f = detail::acceleration_boundary_filter<long double>(n, approximation_order, 0);
|
||||
auto f = detail::acceleration_filter<long double>(n, approximation_order, 0);
|
||||
m_f.resize(n+1);
|
||||
for (size_t i = 0; i < m_f.size(); ++i)
|
||||
{
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
int64_t s = static_cast<int64_t>(i) - static_cast<int64_t>(n);
|
||||
auto bf = detail::acceleration_boundary_filter<long double>(n, approximation_order, s);
|
||||
auto bf = detail::acceleration_filter<long double>(n, approximation_order, s);
|
||||
m_boundary_filters[i].resize(bf.size());
|
||||
for (size_t j = 0; j < bf.size(); ++j)
|
||||
{
|
||||
@@ -343,7 +343,7 @@ public:
|
||||
{
|
||||
// Given that the purpose is denoising, for higher precision calculations,
|
||||
// the default precision should be fine.
|
||||
auto f = detail::acceleration_boundary_filter<Real>(n, approximation_order, 0);
|
||||
auto f = detail::acceleration_filter<Real>(n, approximation_order, 0);
|
||||
m_f.resize(n+1);
|
||||
for (size_t i = 0; i < m_f.size(); ++i)
|
||||
{
|
||||
@@ -353,7 +353,7 @@ public:
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
int64_t s = static_cast<int64_t>(i) - static_cast<int64_t>(n);
|
||||
m_boundary_filters[i] = detail::acceleration_boundary_filter<Real>(n, approximation_order, s);
|
||||
m_boundary_filters[i] = detail::acceleration_filter<Real>(n, approximation_order, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <random>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include <boost/accumulators/statistics/sum_kahan.hpp>
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
#include <boost/math/differentiation/lanczos_smoothing.hpp>
|
||||
@@ -24,8 +23,8 @@ using boost::multiprecision::cpp_bin_float_50;
|
||||
using boost::multiprecision::cpp_bin_float_100;
|
||||
using boost::math::differentiation::discrete_lanczos_derivative;
|
||||
using boost::math::differentiation::detail::discrete_legendre;
|
||||
using boost::math::differentiation::detail::interior_filter;
|
||||
using boost::math::differentiation::detail::boundary_filter;
|
||||
using boost::math::differentiation::detail::interior_velocity_filter;
|
||||
using boost::math::differentiation::detail::boundary_velocity_filter;
|
||||
|
||||
template<class Real>
|
||||
void test_dlp_norms()
|
||||
@@ -161,7 +160,7 @@ void test_dlp_second_derivative()
|
||||
|
||||
|
||||
template<class Real>
|
||||
void test_interior_filter()
|
||||
void test_interior_velocity_filter()
|
||||
{
|
||||
std::cout << "Testing interior filter on type " << typeid(Real).name() << "\n";
|
||||
Real tol = std::numeric_limits<Real>::epsilon();
|
||||
@@ -169,7 +168,7 @@ void test_interior_filter()
|
||||
{
|
||||
for (int p = 1; p < n; p += 2)
|
||||
{
|
||||
auto f = interior_filter<Real>(n,p);
|
||||
auto f = interior_velocity_filter<Real>(n,p);
|
||||
// Since we only store half the filter coefficients,
|
||||
// we need to reindex the moment sums:
|
||||
Real sum = 0;
|
||||
@@ -312,7 +311,7 @@ void test_interior_lanczos()
|
||||
}
|
||||
|
||||
template<class Real>
|
||||
void test_boundary_filters()
|
||||
void test_boundary_velocity_filters()
|
||||
{
|
||||
std::cout << "Testing boundary filters on type " << typeid(Real).name() << "\n";
|
||||
Real tol = std::numeric_limits<Real>::epsilon();
|
||||
@@ -322,7 +321,7 @@ void test_boundary_filters()
|
||||
{
|
||||
for (int s = -n; s <= n; ++s)
|
||||
{
|
||||
auto f = boundary_filter<Real>(n, p, s);
|
||||
auto f = boundary_velocity_filter<Real>(n, p, s);
|
||||
// Sum is zero:
|
||||
Real sum = 0;
|
||||
Real c = 0;
|
||||
@@ -484,7 +483,7 @@ void test_acceleration_filters()
|
||||
{
|
||||
for(int64_t s = -int64_t(n); s <= 0; ++s)
|
||||
{
|
||||
auto g = boost::math::differentiation::detail::acceleration_boundary_filter<long double>(n,p,s);
|
||||
auto g = boost::math::differentiation::detail::acceleration_filter<long double>(n,p,s);
|
||||
|
||||
std::vector<Real> f(g.size());
|
||||
for (size_t i = 0; i < g.size(); ++i)
|
||||
@@ -600,16 +599,16 @@ BOOST_AUTO_TEST_CASE(lanczos_smoothing_test)
|
||||
test_dlp_derivatives<double>();
|
||||
test_dlp_next<double>();
|
||||
test_dlp_norms<cpp_bin_float_50>();
|
||||
test_boundary_filters<double>();
|
||||
test_boundary_filters<long double>();
|
||||
test_boundary_filters<cpp_bin_float_50>();
|
||||
test_boundary_velocity_filters<double>();
|
||||
test_boundary_velocity_filters<long double>();
|
||||
test_boundary_velocity_filters<cpp_bin_float_50>();
|
||||
test_boundary_lanczos<double>();
|
||||
test_boundary_lanczos<long double>();
|
||||
// Takes too long!
|
||||
//test_boundary_lanczos<cpp_bin_float_50>();
|
||||
|
||||
test_interior_filter<double>();
|
||||
test_interior_filter<long double>();
|
||||
test_interior_velocity_filter<double>();
|
||||
test_interior_velocity_filter<long double>();
|
||||
test_interior_lanczos<double>();
|
||||
|
||||
test_acceleration_filters<double>();
|
||||
|
||||
Reference in New Issue
Block a user