Ginger 1.1.9
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
ginger Namespace Reference

Options for convergence-based algorithms. More...

Classes

class  Matrix2
 Matrix2. More...
 
class  Options
 
class  thread_pool
 
class  Vector2
 Vector2. More...
 
class  Vector2Ref
 Vector2Ref. More...
 

Enumerations

enum class  solve_mode { automatic , sequential , multi_threaded , atomic }
 Execution policy selection for the solver facades. More...
 

Functions

auto should_parallelize (std::size_t num_roots) -> bool
 Whether num_roots should use the multi-threaded execution policy.
 
void log_with_spdlog (const std::string &message)
 Log a message using spdlog.
 
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).
 
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).
 
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.
 
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).
 
auto get_thread_pool () -> thread_pool &
 Convenience accessor returning a singleton thread pool.
 

Variables

constexpr std::size_t PARALLEL_THRESHOLD = 4
 Number of roots above which the multi-threaded policies are used by default.
 

Detailed Description

Options for convergence-based algorithms.

Options.

Stores maximum iteration count, tolerance for global convergence, and per-root tolerance for convergence checks used by Bairstow and Aberth root-finding methods.

The code snippet defines a class called Options that represents the options for a specific algorithm or function. It has two public member variables: max_iters and tolerance.

Enumeration Type Documentation

◆ solve_mode

Execution policy selection for the solver facades.

Enumerator
automatic 
sequential 
multi_threaded 
atomic 

Function Documentation

◆ get_thread_pool()

auto ginger::get_thread_pool ( ) -> thread_pool&
inline

Convenience accessor returning a singleton thread pool.

The pool uses hardware concurrency as the number of worker threads. Use this in call sites that do not need to manage pool lifetime.

Returns
Reference to the global thread_pool instance.

◆ log_with_spdlog()

void ginger::log_with_spdlog ( const std::string &  message)

Log a message using spdlog.

This function provides a simple wrapper around spdlog for logging messages. It creates a file logger that writes to "ginger.log" and logs at the info level.

Parameters
messageThe message to log

◆ should_parallelize()

auto ginger::should_parallelize ( std::size_t  num_roots) -> bool
inline

Whether num_roots should use the multi-threaded execution policy.

◆ solve_aberth()

auto ginger::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>
inline

Facade for the Aberth-Ehrlich method.

Parameters
[in]coeffsPolynomial coefficients (highest degree first)
[in,out]zsRoot iterates
[in]optionsConvergence options
[in]modeExecution policy selector
Returns
std::pair<unsigned int, bool> (iterations, converged)

◆ solve_aberth_autocorr()

auto ginger::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>
inline

Facade for the Aberth-Ehrlich method (auto-correlation).

Parameters
[in]coeffsPolynomial coefficients (highest degree first)
[in,out]zsRoot iterates
[in]optionsConvergence options
[in]modeExecution policy selector
Returns
std::pair<unsigned int, bool> (iterations, converged)

◆ solve_pbairstow_autocorr()

auto ginger::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>
inline

Facade for the parallel Bairstow method (auto-correlation).

Parameters
[in]coeffsPolynomial coefficients (highest degree first)
[in,out]vrsQuadratic factor iterates
[in]optionsConvergence options
[in]modeExecution policy selector
Returns
std::pair<unsigned int, bool> (iterations, converged)

◆ solve_pbairstow_even()

auto ginger::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>
inline

Facade for the parallel Bairstow method (even degree).

Selects the execution policy: automatic (default) dispatches to the multi-threaded variant when should_parallelize(vrs.size()) holds, otherwise to the single-threaded variant.

Parameters
[in]coeffsPolynomial coefficients (highest degree first)
[in,out]vrsQuadratic factor iterates
[in]optionsConvergence options
[in]modeExecution policy selector
Returns
std::pair<unsigned int, bool> (iterations, converged)

Variable Documentation

◆ PARALLEL_THRESHOLD

constexpr std::size_t ginger::PARALLEL_THRESHOLD = 4
inlineconstexpr

Number of roots above which the multi-threaded policies are used by default.