52 template<
typename... T>
64 throw std::runtime_error(
"attempting to adjust precision of double to non-double precision");
72 throw std::runtime_error(
"attempting to adjust precision of std::complex<double> to non-double precision");
98 assert(
Precision(current_time)==
Precision(current_sample) &&
"precision of sample and time to be refined in AMP endgame must match");
102 TR.ChangePrecision(
Precision(current_time));
104 auto refinement_success = this->
GetTracker().
Refine(result,current_sample,current_time,
124 auto next_sample_higher_prec = current_sample;
125 Precision(next_sample_higher_prec, higher_precision);
129 auto time_higher_precision = current_time;
130 Precision(time_higher_precision,higher_precision);
134 next_sample_higher_prec,
135 time_higher_precision,
140 result = result_higher_prec;
144 return refinement_success;
159 return this->
GetTracker().
Refine(result, current_sample, current_time, tol, max_iterations);
197 template<
typename TimesTuple>
200 auto& from = std::get<TimeCont<complex_dbl> >(times);
201 auto& to = std::get<TimeCont<complex_mp> >(times);
203 for (
auto const& t : from) to.push_back(
complex_mp(t));
209 template<
typename SampsTuple>
212 auto& from = std::get<SampCont<complex_dbl> >(samps);
213 auto& to = std::get<SampCont<complex_mp> >(samps);
215 for (
auto const& v : from)
218 for (Eigen::Index i = 0; i < v.size(); ++i) w(i) =
complex_mp(v(i));
219 to.push_back(std::move(w));
226 template<
typename VecTuple>
230 auto& from = std::get<Vec<complex_dbl> >(vec);
231 auto& to = std::get<Vec<complex_mp> >(vec);
232 to.resize(from.size());
233 for (Eigen::Index i = 0; i < from.size(); ++i) to(i) =
complex_mp(from(i));
234 if (to.size() > 0)
Precision(to, newprec);
243 for (Eigen::Index i = 0; i < v.size(); ++i) out(i) =
complex_dbl(v(i));
259 template<
typename ComplexT>
264 for (Eigen::Index i = 0; i < v.size(); ++i) out(i) =
complex_mp(v(i));
265 if (out.size() > 0)
Precision(out, prec);
Functions for dealing with precisions of objects, particularly in the context of adaptive precision.
Contains the AMPTracker type, and necessary functions.
void NotifyObservers(AnyEvent const &e) const
Definition observable.hpp:185
Specifies some necessaries for AMP style endgame implementations, which differ from the fixed precisi...
Definition amp_endgame.hpp:46
tracking::AMPTracker TrackerT
The path-tracker type.
Definition amp_endgame.hpp:48
AMPEndgame(TrackerT const &new_tracker)
Construct the AMP endgame precision policy for a tracker.
Definition amp_endgame.hpp:273
Vec< complex_mp > ToBCT(Vec< ComplexT > const &v, unsigned prec) const
Widen a vector to the boundary complex type (complex_mp) at the given precision.
Definition amp_endgame.hpp:260
unsigned current_endgame_precision_
The endgame's current working precision (double = fast lane, higher = mpfr slot).
Definition amp_endgame.hpp:176
void CrossSampsUp(SampsTuple &samps, unsigned newprec) const
Widen a samples container's complex_dbl slot into the complex_mp slot at the new precision.
Definition amp_endgame.hpp:210
AMPEndgame EmitterType
The event-emitter type.
Definition amp_endgame.hpp:49
unsigned NextEscalatedPrecision() const
Return the next (higher) precision to escalate to, following the tracker's authority and strictly abo...
Definition amp_endgame.hpp:182
static unsigned EnsureAtUniformPrecision(T &...args)
Bring a set of values to a common (highest) precision.
Definition amp_endgame.hpp:54
static void EnsureAtPrecision(double &, unsigned prec)
No-op precision check for a double (throws if asked for non-double precision).
Definition amp_endgame.hpp:61
void CrossTimesUp(TimesTuple ×, unsigned newprec) const
Widen a times container's complex_dbl slot into the complex_mp slot at the new precision.
Definition amp_endgame.hpp:198
static void EnsureAtPrecision(std::complex< double > &, unsigned prec)
No-op precision check for a std::complex<double> (throws if asked for non-double precision).
Definition amp_endgame.hpp:69
void CrossVecUp(VecTuple &vec, unsigned newprec) const
Widen a vector container's complex_dbl slot into the complex_mp slot at the new precision.
Definition amp_endgame.hpp:227
bool adaptive_numeric_type_active_
When true, the double-first adaptive-numeric-type lane is armed.
Definition amp_endgame.hpp:177
static void EnsureAtPrecision(complex_mp &obj, unsigned prec)
Set a multiprecision complex to the given precision.
Definition amp_endgame.hpp:85
static void EnsureAtPrecision(real_mp &obj, unsigned prec)
Set a multiprecision real to the given precision.
Definition amp_endgame.hpp:77
complex_mp AtActivePrecisionScalar(complex_mp const &x) const
Copy a complex_mp scalar set to the endgame's active working precision.
Definition amp_endgame.hpp:249
SuccessCode RefineSampleImpl(Vec< complex_mp > &result, Vec< complex_mp > const ¤t_sample, complex_mp const ¤t_time, NumErrorT tol, unsigned max_iterations) const
Refine a single sample point, escalating precision if Newton refinement needs it.
Definition amp_endgame.hpp:94
virtual ~AMPEndgame()=default
SuccessCode RefineSampleImpl(Vec< complex_dbl > &result, Vec< complex_dbl > const ¤t_sample, complex_dbl const ¤t_time, NumErrorT tol, unsigned max_iterations) const
Hardware-double fast-lane refine for the adaptive-numeric-type (double-first) endgame.
Definition amp_endgame.hpp:157
Vec< complex_dbl > DowncastToDouble(Vec< complex_mp > const &v) const
Convert an mp vector down to the hardware complex_dbl fast lane.
Definition amp_endgame.hpp:240
Vec< complex_mp > AtActivePrecisionVec(Vec< complex_mp > const &v) const
Copy a complex_mp vector set to the endgame's active working precision.
Definition amp_endgame.hpp:253
EndgamePrecPolicyBase(tracking::AMPTracker const &new_tracker)
Definition prec_base.hpp:47
const tracking::AMPTracker & GetTracker() const
Definition prec_base.hpp:68
Event emitted when the endgame's working precision changes.
Definition events.hpp:220
Functor-like class for tracking paths on a system.
Definition amp_tracker.hpp:409
unsigned GetCurrentPrecision() const
Get the current working precision of the adaptive tracker.
Definition amp_tracker.hpp:450
SuccessCode ChangePrecision(unsigned new_precision) const
Change precision of tracker to next_precision.
Definition amp_tracker.hpp:1419
SuccessCode Refine(Vec< C > &new_space, Vec< C > const &start_point, C const ¤t_time) const
Refine a point to tolerance implicitly internally set.
Definition base_tracker.hpp:409
Configs and settings for endgames.
Contains the endgames/events base types.
Definition endgames.hpp:44
void SetPrecision(SampCont< complex_mp > &samples, unsigned prec)
Sets the precision of each space sample to be of input precision.
Definition adaptive_precision_utilities.hpp:44
unsigned EnsureAtUniformPrecision(TimeCont< complex_dbl > &, SampCont< complex_dbl > &)
Does not a thing, because cannot.
Definition adaptive_precision_utilities.hpp:107
Definition adaptive_precision_utilities.hpp:35
Definition algorithm_builder.hpp:36
constexpr unsigned DoublePrecision()
The number of digits considered "double precision" (16).
Definition num_traits.hpp:152
std::complex< double > complex_dbl
The double-precision complex number type.
Definition double_extensions.hpp:47
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
unsigned PrecisionIncrement()
The number of digits by which adaptive precision is increased at each step.
Definition num_traits.hpp:145
void SetThreadPrecision(unsigned prec)
Set the precision (digits) for the current thread only (does not touch the global default).
Definition mpfr_complex.hpp:176
double NumErrorT
The numeric type used to hold error/tolerance magnitudes throughout Bertini2 – tracking tolerances,...
Definition num_traits.hpp:48
bmp::number< mpc_complex_backend< 0 >, bmp::et_on > complex_mp
The arbitrary-precision complex number type.
Definition mpfr_complex.hpp:58
SuccessCode
Definition config.hpp:42
@ FailedToConverge
Definition config.hpp:55
@ HigherPrecisionNecessary
Definition config.hpp:52
boost::multiprecision::number< boost::multiprecision::mpfr_float_backend< 0 >, boost::multiprecision::et_on > real_mp
The arbitrary-precision real number type.
Definition mpfr_extensions.hpp:53
constexpr unsigned LowestMultiplePrecision()
The lowest multiple-precision digit count used (20).
Definition num_traits.hpp:159
unsigned ThreadPrecision()
Get the current thread's precision (digits).
Definition mpfr_complex.hpp:183
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object.
Definition eigen_extensions.hpp:339
T max(T const &a, T const &b, T const &c)
Three-argument form of max.
Definition mpfr_extensions.hpp:96
Contains the observable base types.
Contains a parent class, EndgamePrecPolicyBase (an observable), from which the fixed double,...
AMPEndgame type
The endgame precision-policy type for this tracker.
Definition amp_endgame.hpp:285
Base empty class.
Definition config.hpp:64