ginger/rootfinding.hpp file

Classes

class Options
Options.

Typedefs

using Vec2 = numeric::Vector2<double>
using Mat2 = numeric::Matrix2<Vec2>

Functions

auto initial_guess(std::vector<double> coeffs) -> std::vector< Vec2 > -> auto
Initial guess for the parallel Bairstow method.
auto pbairstow_even(const std::vector<double>& coeffs, std::vector<Vec2>& vrs, const Options& options) -> std::pair< unsigned int, bool > -> auto
Multi-threading Bairstow's method (even degree only)
auto horner(std::vector<double>& coeffs1, std::size_t degree, const Vec2& vr) -> Vec2 -> auto
Horner's rule.
auto suppress(Vec2& vA, Vec2& vA1, const Vec2& vri, const Vec2& vrj) -> void -> auto
zero suppression
auto suppress2(Vec2& vA, Vec2& vA1, const Vec2& vri, const Vec2& vrj) -> void -> auto
zero suppression
auto makeadjoint(const Vec2& vr, const Vec2& vp) -> Mat2 -> auto
auto delta(const Vec2& vA, const Vec2& vr, const Vec2& vp) -> Vec2 -> auto
auto horner_eval(std::vector<double> coeffs1, std::size_t degree, const double& z) -> double -> auto

Function documentation

auto initial_guess(std::vector<double> coeffs) -> std::vector< Vec2 >

Initial guess for the parallel Bairstow method.

Parameters
coeffs in coeffs is a vector of doubles that represents the coefficients of a polynomial.
Returns The function initial_guess returns a vector of Vec2 objects.

The initial_guess function calculates the initial values for the parallel Bairstow method for finding the roots of a real polynomial.

auto pbairstow_even(const std::vector<double>& coeffs, std::vector<Vec2>& vrs, const Options& options) -> std::pair< unsigned int, bool >

Multi-threading Bairstow's method (even degree only)

Parameters
coeffs in The coeffs parameter is a vector representing the coefficients of the polynomial. Each element of the vector corresponds to the coefficient of a term in the polynomial, starting from the highest degree term and ending with the constant term. For example, if the polynomial is `3x^2 + 2
vrs in/out vrs is a vector of iterates, which represents the initial guesses for the roots of the polynomial. The Bairstow's method will update these iterates iteratively until the desired tolerance is reached or the maximum number of iterations is reached.
options in The options parameter is an object of type Options which contains the maximum number of iterations (max_iters) and the tolerance (tolerance). These options are used to control the convergence criteria for the Bairstow's method.
Returns The function pbairstow_even returns a std::pair<unsigned int, bool>. The first element of the pair represents the number of iterations performed, and the second element represents whether the method converged to a solution within the specified tolerance.

The pbairstow_even function implements Bairstow's method for finding the roots of a real polynomial with an even degree using multi-threading.

auto horner(std::vector<double>& coeffs1, std::size_t degree, const Vec2& vr) -> Vec2

Horner's rule.

Parameters
coeffs1 in/out coeffs1 is a reference to a vector of doubles. It is used to store the coefficients of a polynomial.
degree in The parameter degree represents the size of the vector coeffs1. It indicates the number of elements in the vector coeffs1.
vr in vr is a Vec2 object, which represents a 2D vector. It has two components, vr.x() and vr.y(), which are used in the calculations inside the horner function.
Returns a Vec2 object.

Horner's rule is a method for evaluating a polynomial of degree degree at a given point x. It involves rewriting the polynomial as a nested multiplication and addition of the form:

P(x) = a_0 + x(a_1 + x(a_2 + ... + x(a_{degree-1} + x(a_n))...))

This form allows for efficient evaluation of the polynomial at a given point x using only degree multiplications and degree additions. Horner's rule is commonly used in numerical methods for polynomial evaluation and interpolation.

auto suppress(Vec2& vA, Vec2& vA1, const Vec2& vri, const Vec2& vrj) -> void

zero suppression

Parameters
vA in/out
vA1 in/out
vri in
vrj in

zero suppression is a technique used in the Bairstow method to find the coefficients of the linear remainder of a deflated polynomial without explicitly constructing the deflated polynomial. The goal of zero suppression is to perform the Bairstow process without the need for complex arithmetic within iterations. The technique involves finding the coefficients of the linear remainder of the deflated polynomial using the coefficients of the linear remainder of the original polynomial and the known factor of the original polynomial.

auto suppress2(Vec2& vA, Vec2& vA1, const Vec2& vri, const Vec2& vrj) -> void

zero suppression

Parameters
vA in/out
vA1 in/out
vri in
vrj in

zero suppression is a technique used in the Bairstow method to find the coefficients of the linear remainder of a deflated polynomial without explicitly constructing the deflated polynomial. The goal of zero suppression is to perform the Bairstow process without the need for complex arithmetic within iterations. The technique involves finding the coefficients of the linear remainder of the deflated polynomial using the coefficients of the linear remainder of the original polynomial and the known factor of the original polynomial.

auto makeadjoint(const Vec2& vr, const Vec2& vp) -> Mat2

Parameters
vr in A constant reference to a Vec2 object, representing the vector vr.
vp in vp is a vector with two components, vp.x() and vp.y().
Returns a Mat2 object.

The function "makeadjoint" takes in a vector vr and a vector vp, and returns a 2x2 matrix where the elements are calculated based on the values of vr and vp.

auto delta(const Vec2& vA, const Vec2& vr, const Vec2& vp) -> Vec2

Parameters
vA in A vector of type Vec2.
vr in A vector representing the direction of rotation.
vp in The parameter vp is a Vec2 object that is passed by rvalue reference.
Returns a Vec2 object.

The function calculates the delta value using the given parameters.

auto horner_eval(std::vector<double> coeffs1, std::size_t degree, const double& z) -> double

Parameters
coeffs1 in/out A vector of coefficients for a polynomial, where the coefficient at index i corresponds to the term with degree i.
degree in The degree parameter represents the degree of the polynomial. It indicates the highest power of the variable in the polynomial equation.
in The parameter z is a constant value that is used as the input to the polynomial function being evaluated.
Returns a double value.

The function horner_eval evaluates a polynomial using Horner's method.