Ginger 1.1.5; VERSION ${PROJECT_VERSION}
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
19class Options;
20
42extern auto horner_ref(std::vector<double>& coeffs, std::vector<Vec2Ref>& vcoeffs,
43 std::size_t degree, const Vec2& vr) -> Vec2Ref;
44
90extern auto bairstow(const std::vector<double>& coeffs, Vec2& vr, const Options& options)
91 -> std::pair<unsigned int, bool>;
92
107inline auto makeadjoint_ref(const Vec2& vr, const Vec2Ref& vp) -> Mat2 {
108 auto p = vp.x();
109 auto s = vp.y();
110 return {Vec2{s, -p}, Vec2{-p * vr.y(), p * vr.x() + s}};
111}
112
127inline auto delta_ref(const Vec2Ref& vA, const Vec2& vr, const Vec2Ref& vp) -> Vec2 {
128 const auto mp = makeadjoint_ref(vr, vp); // 2 mul's
129 return mp.mdot(vA) / mp.det(); // 6 mul's + 2 div's
130}
auto bairstow(const std::vector< double > &coeffs, Vec2 &vr, const 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:127
auto makeadjoint_ref(const Vec2 &vr, const Vec2Ref &vp) -> Mat2
Create adjoint matrix from two vectors (reference-based)
Definition bairstow.hpp:107
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)
Options for convergence-based algorithms.
Definition config.hpp:15
Matrix2.
Definition matrix2.hpp:28
constexpr auto x() const -> const T1 &
Get the first column vector.
Definition matrix2.hpp:47
Vector2.
Definition vector2.hpp:19
constexpr auto y() const noexcept -> const T2 &
Definition vector2.hpp:81
2x2 matrix template for polynomial root-finding