Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
fixed_prec_endgame.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//fixed_prec_endgame.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//fixed_prec_endgame.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with fixed_prec_endgame.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2015 - 2021 by Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22// individual authors of this file include:
23// silviana amethyst, university of wisconsin eau claire
24// Tim Hodges, Colorado State University
25
26
27
28
29#pragma once
30
36
38#include "bertini2/trackers/fixed_precision_utilities.hpp"
39
42
43
44namespace bertini{ namespace endgame {
45
46template<typename TrackerT>
47class FixedPrecEndgame : public virtual EndgamePrecPolicyBase<TrackerT>
48{
49public:
50 using TrackerType = TrackerT;
51 using BaseComplexType = typename tracking::TrackerTraits<TrackerType>::BaseComplexType;
52 using BaseRealType = typename tracking::TrackerTraits<TrackerType>::BaseRealType;
53
54 using BCT = BaseComplexType;
55 using BRT = BaseRealType;
56
57 template<typename... T>
58 static
59 unsigned EnsureAtUniformPrecision(T& ...args)
60 {
61 return bertini::tracking::fixed::EnsureAtUniformPrecision(args...);
62 }
63
64 template<typename T>
65 static
66 void EnsureAtPrecision(T const & obj, unsigned prec)
67 {
69 if (Precision(obj)!=prec)
70 {
71 std::stringstream err_msg;
72 err_msg << "ensuring precision of object failed; precision is " << Precision(obj) << " and required precision is " << prec;
73 throw std::runtime_error(err_msg.str());
74 }
75 }
76
77 SuccessCode RefineSampleImpl(Vec<BCT> & result, Vec<BCT> const& current_sample, BCT const& current_time, double tol, unsigned max_iterations) const
78 {
79 using RT = mpfr_float;
80 using std::max;
81 auto& TR = this->GetTracker();
82
83 auto refinement_success = this->GetTracker().Refine(result,current_sample,current_time,
84 tol,
85 max_iterations);
86
87 return SuccessCode::Success;
88 }
89
90 explicit
91 FixedPrecEndgame(TrackerT const& new_tracker) : EndgamePrecPolicyBase<TrackerT>(new_tracker)
92 {}
93
94 virtual ~FixedPrecEndgame() = default;
95}; // re: fixed prec endgame policy
96
97template<>
98struct EGPrecSelector<tracking::DoublePrecisionTracker>
99{
100 using type = FixedPrecEndgame<tracking::DoublePrecisionTracker>;
101};
102
103template<>
104struct EGPrecSelector<tracking::MultiplePrecisionTracker>
105{
106 using type = FixedPrecEndgame<tracking::MultiplePrecisionTracker>;
107};
108
109template<class D>
110struct EGPrecSelector<tracking::FixedPrecisionTracker<D>>
111{
112 using type = FixedPrecEndgame<tracking::FixedPrecisionTracker<D>>;
113};
114
115}} //re: namespaces
116
117
118
119
A common base type for various precision types, fixed and adaptive. The purpose of this is to maintai...
Definition prec_base.hpp:46
const TrackerT & GetTracker() const
Getter for the tracker used inside an instance of the endgame.
Definition prec_base.hpp:73
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object. If the object is empty, it's the precision of a default-constru...
Definition eigen_extensions.hpp:292
Configs and settings for endgames.
Contains a parent class, EndgamePrecPolicyBase (an observable), from which the fixed double,...
Definition endgames/config.hpp:67