2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-01 20:42:19 +00:00
Files
math/reporting/performance/chebyshev_clenshaw.cpp
Nick c59659f4ed Reinch's modification to Clenshaw recurrence (#339)
* Reinch's modification to Clenshaw recurrence. [CI SKIP]

* Convert Chebyshev tests to math_unit_test.hpp

* Performance of translated Chebyshev Clenshaw recurrence. [CI SKIP]

* Prepare to use modified Clenshaw recurrence in Chebyshev transform.

* Remove unused headers from Chebyshev transform test [CI SKIP]

* Update Chebyshev transform tests to use math_unit_test.hpp
2020-04-25 09:01:05 -04:00

57 lines
1.5 KiB
C++

#include <vector>
#include <random>
#include <benchmark/benchmark.h>
#include <boost/math/special_functions/chebyshev.hpp>
template<class Real>
void ChebyshevClenshaw(benchmark::State& state)
{
std::vector<Real> v(state.range(0));
std::random_device rd;
std::mt19937_64 mt(rd());
std::uniform_real_distribution<Real> unif(-1,1);
for (size_t i = 0; i < v.size(); ++i)
{
v[i] = unif(mt);
}
using boost::math::chebyshev_clenshaw_recurrence;
Real x = unif(mt);
for (auto _ : state)
{
benchmark::DoNotOptimize(chebyshev_clenshaw_recurrence(v.data(), v.size(), x));
}
state.SetComplexityN(state.range(0));
}
template<class Real>
void TranslatedChebyshevClenshaw(benchmark::State& state)
{
std::vector<Real> v(state.range(0));
std::random_device rd;
std::mt19937_64 mt(rd());
std::uniform_real_distribution<Real> unif(-1,1);
for (size_t i = 0; i < v.size(); ++i)
{
v[i] = unif(mt);
}
using boost::math::detail::unchecked_chebyshev_clenshaw_recurrence;
Real x = unif(mt);
Real a = -2;
Real b = 5;
for (auto _ : state)
{
benchmark::DoNotOptimize(unchecked_chebyshev_clenshaw_recurrence(v.data(), v.size(), a, b, x));
}
state.SetComplexityN(state.range(0));
}
BENCHMARK_TEMPLATE(TranslatedChebyshevClenshaw, double)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity(benchmark::oN);
BENCHMARK_TEMPLATE(ChebyshevClenshaw, double)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity(benchmark::oN);
BENCHMARK_MAIN();