mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 16:32:10 +00:00
* Implement logaddexp * Disable test for ASAN * Implement logsumexp * Add performance file and include results in the docs * Address review comments * Simplify overflow test and comply with min/max guidelines * Minor cleanup * FIxes to comments and docs [ci skip] * Return status code. Co-authored-by: Nick Thompson <nathompson7@protonmail.com>
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
// (C) Copyright Matt Borland 2022.
|
|
// 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 <random>
|
|
#include <limits>
|
|
#include <benchmark/benchmark.h>
|
|
#include <boost/math/special_functions/logaddexp.hpp>
|
|
|
|
using boost::math::logaddexp;
|
|
|
|
template <typename Real>
|
|
void logaddexp_performance(benchmark::State& state)
|
|
{
|
|
std::random_device rd;
|
|
std::mt19937_64 mt {rd()};
|
|
std::uniform_real_distribution<long double> dist(1e-50, 5e-50);
|
|
|
|
Real x = static_cast<Real>(dist(mt));
|
|
Real y = static_cast<Real>(dist(mt));
|
|
|
|
for (auto _ : state)
|
|
{
|
|
benchmark::DoNotOptimize(logaddexp(x, y));
|
|
x += std::numeric_limits<Real>::epsilon();
|
|
y += std::numeric_limits<Real>::epsilon();
|
|
}
|
|
}
|
|
|
|
BENCHMARK_TEMPLATE(logaddexp_performance, float);
|
|
BENCHMARK_TEMPLATE(logaddexp_performance, double);
|
|
BENCHMARK_TEMPLATE(logaddexp_performance, long double);
|
|
|
|
BENCHMARK_MAIN();
|