Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
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) 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#pragma once
23
29
32
35
36
37namespace bertini{ namespace endgame {
38
40template<typename TrackerT>
41class FixedPrecEndgame : public virtual EndgamePrecPolicyBase<TrackerT>
42{
43public:
44 using TrackerType = TrackerT;
47
48 using BCT = BaseComplexT;
49 using BRT = BaseRealT;
50
52 template<typename... T>
53 static
54 unsigned EnsureAtUniformPrecision(T& ...args)
55 {
57 }
58
60 template<typename T>
61 static
62 void EnsureAtPrecision(T const & obj, unsigned prec)
63 {
65 if (Precision(obj)!=prec)
66 {
67 std::stringstream err_msg;
68 err_msg << "ensuring precision of object failed; precision is " << Precision(obj) << " and required precision is " << prec;
69 throw std::runtime_error(err_msg.str());
70 }
71 }
72
74 SuccessCode RefineSampleImpl(Vec<BCT> & result, Vec<BCT> const& current_sample, BCT const& current_time, NumErrorT tol, unsigned max_iterations) const
75 {
76 auto refinement_success = this->GetTracker().Refine(result,current_sample,current_time,
77 tol,
78 max_iterations);
79
80 return refinement_success;
81 }
82
84 explicit
85 FixedPrecEndgame(TrackerT const& new_tracker) : EndgamePrecPolicyBase<TrackerT>(new_tracker)
86 {}
87
88 virtual ~FixedPrecEndgame() = default;
89}; // re: fixed prec endgame policy
90
92template<>
97
99template<>
100struct EGPrecSelector<tracking::MultiplePrecisionTracker>
101{
103};
104
106template<class D>
107struct EGPrecSelector<tracking::FixedPrecisionTracker<D>>
108{
110};
111
112}} //re: namespaces
EndgamePrecPolicyBase(TrackerT const &new_tracker)
Construct the precision policy holding a reference to the given tracker.
Definition prec_base.hpp:47
const TrackerT & GetTracker() const
Getter for the tracker used inside an instance of the endgame.
Definition prec_base.hpp:68
Fixed-precision endgame precision policy (refines and ensures precision at a single working precision...
Definition fixed_prec_endgame.hpp:42
BaseComplexT BCT
The complex number type.
Definition fixed_prec_endgame.hpp:48
static void EnsureAtPrecision(T const &obj, unsigned prec)
Assert that an object is already at the given precision (throws otherwise).
Definition fixed_prec_endgame.hpp:62
typename tracking::TrackerTraits< TrackerType >::BaseComplexT BaseComplexT
The complex number type.
Definition fixed_prec_endgame.hpp:45
FixedPrecEndgame(TrackerT const &new_tracker)
Construct the fixed-precision endgame policy for a tracker.
Definition fixed_prec_endgame.hpp:85
typename tracking::TrackerTraits< TrackerType >::BaseRealT BaseRealT
The real number type.
Definition fixed_prec_endgame.hpp:46
TrackerT TrackerType
The path-tracker type.
Definition fixed_prec_endgame.hpp:44
SuccessCode RefineSampleImpl(Vec< BCT > &result, Vec< BCT > const &current_sample, BCT const &current_time, NumErrorT tol, unsigned max_iterations) const
Refine a single sample point at the (fixed) working precision.
Definition fixed_prec_endgame.hpp:74
BaseRealT BRT
The real number type.
Definition fixed_prec_endgame.hpp:49
static unsigned EnsureAtUniformPrecision(T &...args)
Bring a set of values to a common precision (a no-op of effect under fixed precision).
Definition fixed_prec_endgame.hpp:54
Configs and settings for endgames.
Definition endgames.hpp:44
unsigned EnsureAtUniformPrecision(TimeCont< complex_dbl > const &, SampCont< complex_dbl > const &)
Definition fixed_precision_utilities.hpp:68
Definition adaptive_precision_utilities.hpp:35
Definition algorithm_builder.hpp:36
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
double NumErrorT
The numeric type used to hold error/tolerance magnitudes throughout Bertini2 – tracking tolerances,...
Definition num_traits.hpp:48
SuccessCode
Definition config.hpp:42
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object.
Definition eigen_extensions.hpp:339
Contains a parent class, EndgamePrecPolicyBase (an observable), from which the fixed double,...
FixedPrecEndgame< tracking::DoublePrecisionTracker > type
The endgame precision-policy type.
Definition fixed_prec_endgame.hpp:95
FixedPrecEndgame< tracking::FixedPrecisionTracker< D > > type
The endgame precision-policy type.
Definition fixed_prec_endgame.hpp:109
FixedPrecEndgame< tracking::MultiplePrecisionTracker > type
The endgame precision-policy type.
Definition fixed_prec_endgame.hpp:102
Base empty class.
Definition config.hpp:64
Trait lookup mapping a tracker type to its numeric types, event-emitter type, precision config,...
Definition config.hpp:387