1 // (C) Copyright Nick Thompson 2021.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #include <benchmark/benchmark.h>
11 #include <boost/math/tools/cubic_roots.hpp>
13 using boost::math::tools::cubic_roots
;
16 void CubicRoots(benchmark::State
& state
)
18 std::random_device rd
;
20 // This seed generates 3 real roots:
21 //uint32_t seed = 416683252;
22 std::mt19937_64
mt(seed
);
23 std::uniform_real_distribution
<Real
> unif(-10, 10);
31 auto roots
= cubic_roots(a
,b
,c
,d
);
32 benchmark::DoNotOptimize(roots
[0]);
36 BENCHMARK_TEMPLATE(CubicRoots
, float);
37 BENCHMARK_TEMPLATE(CubicRoots
, double);
38 BENCHMARK_TEMPLATE(CubicRoots
, long double);