forked from mpusz/mp-units
Use std::accumulate
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <numeric>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
@@ -88,9 +89,7 @@ constexpr auto coprimes_up_to(std::size_t n, const std::array<std::size_t, N> &b
|
|||||||
|
|
||||||
template<std::size_t N>
|
template<std::size_t N>
|
||||||
constexpr std::size_t product(const std::array<std::size_t, N> &values) {
|
constexpr std::size_t product(const std::array<std::size_t, N> &values) {
|
||||||
std::size_t product = 1;
|
return std::accumulate(std::begin(values), std::end(values), std::size_t{1u}, std::multiplies{});
|
||||||
for (const auto &v : values) { product *= v; }
|
|
||||||
return product;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A configurable instantiation of the "wheel factorization" algorithm [1] for prime numbers.
|
// A configurable instantiation of the "wheel factorization" algorithm [1] for prime numbers.
|
||||||
|
Reference in New Issue
Block a user