Ginger 1.1.11
Loading...
Searching...
No Matches
solve.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <complex> // for complex
9#include <utility> // for pair
10#include <vector> // for vector
11
12#include "aberth.hpp" // for aberth, aberth_autocorr
13#include "aberth_atomic.hpp" // for aberth_atomic, aberth_autocorr_atomic
14#include "aberth_mt.hpp" // for aberth_mt, aberth_autocorr_mt
15#include "autocorr.hpp" // for pbairstow_autocorr_st
16#include "autocorr_atomic.hpp" // for pbairstow_autocorr_atomic
17#include "autocorr_mt.hpp" // for pbairstow_autocorr_mt
18#include "config.hpp" // for ginger::Options, should_parallelize
19#include "rootfinding.hpp" // for pbairstow_even_st
20#include "rootfinding_atomic.hpp" // for pbairstow_even_atomic
21#include "rootfinding_mt.hpp" // for pbairstow_even_mt
22
23namespace ginger {
24
27
39 inline auto solve_pbairstow_even(const std::vector<double>& coeffs, std::vector<Vec2>& vrs,
40 const Options& options,
42 -> std::pair<unsigned int, bool> {
43 switch (mode) {
45 return pbairstow_even_st(coeffs, vrs, options);
47 return pbairstow_even_mt(coeffs, vrs, options);
49 return pbairstow_even_atomic(coeffs, vrs, options);
51 default:
52 return should_parallelize(vrs.size()) ? pbairstow_even_mt(coeffs, vrs, options)
53 : pbairstow_even_st(coeffs, vrs, options);
54 }
55 }
56
63 inline auto solve_pbairstow_autocorr(const std::vector<double>& coeffs, std::vector<Vec2>& vrs,
64 const Options& options,
66 -> std::pair<unsigned int, bool> {
67 switch (mode) {
69 return pbairstow_autocorr_st(coeffs, vrs, options);
71 return pbairstow_autocorr_mt(coeffs, vrs, options);
73 return pbairstow_autocorr_atomic(coeffs, vrs, options);
75 default:
76 return should_parallelize(vrs.size()) ? pbairstow_autocorr_mt(coeffs, vrs, options)
77 : pbairstow_autocorr_st(coeffs, vrs, options);
78 }
79 }
80
87 inline auto solve_aberth(const std::vector<double>& coeffs,
88 std::vector<std::complex<double>>& zs, const Options& options,
90 -> std::pair<unsigned int, bool> {
91 switch (mode) {
93 return aberth(coeffs, zs, options);
95 return aberth_mt(coeffs, zs, options);
97 return aberth_atomic(coeffs, zs, options);
99 default:
100 return should_parallelize(zs.size()) ? aberth_mt(coeffs, zs, options)
101 : aberth(coeffs, zs, options);
102 }
103 }
104
111 inline auto solve_aberth_autocorr(const std::vector<double>& coeffs,
112 std::vector<std::complex<double>>& zs, const Options& options,
114 -> std::pair<unsigned int, bool> {
115 switch (mode) {
117 return aberth_autocorr(coeffs, zs, options);
119 return aberth_autocorr_mt(coeffs, zs, options);
121 return aberth_autocorr_atomic(coeffs, zs, options);
123 default:
124 return should_parallelize(zs.size()) ? aberth_autocorr_mt(coeffs, zs, options)
125 : aberth_autocorr(coeffs, zs, options);
126 }
127 }
128
129} // namespace ginger
Aberth-Ehrlich method for polynomial root-finding.
auto aberth_autocorr(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Single-threading Aberth-Ehrlich method (specifically for auto-correlation functions).
auto aberth(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Single-threading Aberth-Ehrlich method.
Aberth-Ehrlich method for polynomial root-finding (atomic).
auto aberth_autocorr_atomic(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Atomic Aberth-Ehrlich method (specifically for auto-correlation functions).
auto aberth_atomic(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Atomic Aberth-Ehrlich method.
Aberth-Ehrlich method for polynomial root-finding (MT).
auto aberth_mt(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Multi-threading Aberth-Ehrlich method.
auto aberth_autocorr_mt(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Multi-threading Aberth-Ehrlich method (specifically for auto-correlation functions).
Auto-correlation polynomial root-finding (palindromic polynomials).
auto pbairstow_autocorr_st(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Single-threading Bairstow's method (specific for auto-correlation function).
Auto-correlation polynomial root-finding (palindromic polynomials) (atomic).
auto pbairstow_autocorr_atomic(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Atomic multi-threading Bairstow's method (specific for auto-correlation function).
Auto-correlation polynomial root-finding (palindromic polynomials) (MT).
auto pbairstow_autocorr_mt(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Multi-threading Bairstow's method (specific for auto-correlation function).
Definition config.hpp:22
Algorithm options (max iterations, tolerance).
Options for convergence-based algorithms.
Definition aberth.hpp:13
auto solve_aberth(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const Options &options, solve_mode mode=solve_mode::automatic) -> std::pair< unsigned int, bool >
Facade for the Aberth-Ehrlich method.
Definition solve.hpp:87
auto should_parallelize(std::size_t num_roots) -> bool
Whether num_roots should use the multi-threaded execution policy.
Definition config.hpp:33
auto solve_pbairstow_autocorr(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const Options &options, solve_mode mode=solve_mode::automatic) -> std::pair< unsigned int, bool >
Facade for the parallel Bairstow method (auto-correlation).
Definition solve.hpp:63
auto solve_pbairstow_even(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const Options &options, solve_mode mode=solve_mode::automatic) -> std::pair< unsigned int, bool >
Facade for the parallel Bairstow method (even degree).
Definition solve.hpp:39
auto solve_aberth_autocorr(const std::vector< double > &coeffs, std::vector< std::complex< double > > &zs, const Options &options, solve_mode mode=solve_mode::automatic) -> std::pair< unsigned int, bool >
Facade for the Aberth-Ehrlich method (auto-correlation).
Definition solve.hpp:111
solve_mode
Execution policy selection for the solver facades.
Definition solve.hpp:26
@ atomic
Definition solve.hpp:26
@ automatic
Definition solve.hpp:26
@ sequential
Definition solve.hpp:26
@ multi_threaded
Definition solve.hpp:26
Parallel Bairstow root-finding methods for real polynomials.
auto pbairstow_even_st(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Single-threading Bairstow's method (even degree only).
Parallel Bairstow root-finding methods for real polynomials (atomic).
auto pbairstow_even_atomic(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Atomic multi-threading Bairstow's method (even degree only).
Parallel Bairstow root-finding methods for real polynomials (MT).
auto pbairstow_even_mt(const std::vector< double > &coeffs, std::vector< Vec2 > &vrs, const ginger::Options &options) -> std::pair< unsigned int, bool >
Multi-threading Bairstow's method (even degree only).