Ginger 1.1.11
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <algorithm> // for max
9#include <cmath> // for abs
10#include <cstddef> // for size_t
11#include <vector> // for vector
12
20namespace ginger {
21
22 class Options {
23 public:
24 unsigned int max_iters = 2000U;
25 double tolerance = 1e-12;
26 double tol_ind = 1e-15;
27 };
28
30 inline constexpr std::size_t PARALLEL_THRESHOLD = 4;
31
33 inline auto should_parallelize(std::size_t num_roots) -> bool {
34 return num_roots > PARALLEL_THRESHOLD;
35 }
36
53 inline auto residual_scale(const std::vector<double>& coeffs) -> double {
54 auto scale = 1.0;
55 for (const auto coeff : coeffs) {
56 scale = std::max(scale, std::abs(coeff));
57 }
58 return scale;
59 }
60
61} // namespace ginger
Definition config.hpp:22
double tol_ind
Definition config.hpp:26
unsigned int max_iters
Definition config.hpp:24
double tolerance
Definition config.hpp:25
Options for convergence-based algorithms.
Definition aberth.hpp:13
auto should_parallelize(std::size_t num_roots) -> bool
Whether num_roots should use the multi-threaded execution policy.
Definition config.hpp:33
auto residual_scale(const std::vector< double > &coeffs) -> double
Normalisation factor making the convergence test scale-invariant.
Definition config.hpp:53
constexpr std::size_t PARALLEL_THRESHOLD
Number of roots above which the multi-threaded policies are used by default.
Definition config.hpp:30