Ginger 1.1.9
Loading...
Searching...
No Matches
bairstow.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <utility>
9#include <vector>
10
11#include "matrix2.hpp"
12#include "vector2.hpp"
13// #include "vector2_ref.hpp"
14
18
19namespace ginger {
20 class Options;
21}
22
44extern auto horner_ref(std::vector<double>& coeffs, std::vector<Vec2Ref>& vcoeffs,
45 std::size_t degree, const Vec2& vr) -> Vec2Ref;
46
92extern auto bairstow(const std::vector<double>& coeffs, Vec2& vr, const ginger::Options& options)
93 -> std::pair<unsigned int, bool>;
94
109inline auto makeadjoint_ref(const Vec2& vr, const Vec2Ref& vp) -> Mat2 {
110 auto p = vp.x();
111 auto s = vp.y();
112 return {Vec2{s, -p}, Vec2{-p * vr.y(), p * vr.x() + s}};
113}
114
129inline auto delta_ref(const Vec2Ref& vA, const Vec2& vr, const Vec2Ref& vp) -> Vec2 {
130 const auto mp = makeadjoint_ref(vr, vp); // 2 mul's
131 return mp.mdot(vA) / mp.det(); // 6 mul's + 2 div's
132}
constexpr auto make_vdc_table() -> std::array< double, N >
Helper to generate a constexpr table of VdCorput<Base> values.
Definition aberth.hpp:21
auto bairstow(const std::vector< double > &coeffs, Vec2 &vr, const ginger::Options &options) -> std::pair< unsigned int, bool >
Bairstow's method.
ginger::Vector2< double & > Vec2Ref
Definition bairstow.hpp:17
auto delta_ref(const Vec2Ref &vA, const Vec2 &vr, const Vec2Ref &vp) -> Vec2
Calculate Newton correction delta (reference-based)
Definition bairstow.hpp:129
auto makeadjoint_ref(const Vec2 &vr, const Vec2Ref &vp) -> Mat2
Create adjoint matrix from two vectors (reference-based)
Definition bairstow.hpp:109
auto horner_ref(std::vector< double > &coeffs, std::vector< Vec2Ref > &vcoeffs, std::size_t degree, const Vec2 &vr) -> Vec2Ref
Horner's rule (reference-based Vec2 version)
Matrix2.
Definition matrix2.hpp:28
constexpr auto x() const -> const T1 &
Get the first column vector.
Definition matrix2.hpp:47
Definition config.hpp:19
Vector2.
Definition vector2.hpp:19
constexpr auto y() const noexcept -> const T2 &
Definition vector2.hpp:81
2x2 matrix template for polynomial root-finding
Options for convergence-based algorithms.
Definition aberth.hpp:13