51class AMPEndgame :
public virtual EndgamePrecPolicyBase<tracking::AMPTracker>
55 using EmitterType = AMPEndgame;
57 template<
typename... T>
59 unsigned EnsureAtUniformPrecision(T& ...args)
65 void EnsureAtPrecision(
double & obj,
unsigned prec)
67 if (prec!=DoublePrecision())
68 throw std::runtime_error(
"attempting to adjust precision of double to non-double precision");
72 void EnsureAtPrecision(std::complex<double> & obj,
unsigned prec)
74 if (prec!=DoublePrecision())
75 throw std::runtime_error(
"attempting to adjust precision of std::complex<double> to non-double precision");
79 void EnsureAtPrecision(mpfr_float & obj,
unsigned prec)
86 void EnsureAtPrecision(mpfr_complex & obj,
unsigned prec)
94 SuccessCode RefineSampleImpl(Vec<mpfr_complex> & result, Vec<mpfr_complex>
const& current_sample, mpfr_complex
const& current_time, NumErrorT tol,
unsigned max_iterations)
const
98 assert(
Precision(current_time)==
Precision(current_sample) &&
"precision of sample and time to be refined in AMP endgame must match");
100 using RT = mpfr_float;
103 TR.ChangePrecision(
Precision(current_time));
105 auto refinement_success = this->
GetTracker().
Refine(result,current_sample,current_time,
110 if (refinement_success==SuccessCode::HigherPrecisionNecessary ||
111 refinement_success==SuccessCode::FailedToConverge)
117 auto prev_precision = DefaultPrecision();
118 auto higher_precision =
max(prev_precision,LowestMultiplePrecision())+ PrecisionIncrement();
119 DefaultPrecision(higher_precision);
122 NotifyObservers(PrecisionChanged<EmitterType>(*
this, prev_precision, higher_precision));
124 auto next_sample_higher_prec = current_sample;
125 Precision(next_sample_higher_prec, higher_precision);
127 auto result_higher_prec = Vec<mpfr_complex>(current_sample.size());
129 auto time_higher_precision = current_time;
130 Precision(time_higher_precision,higher_precision);
132 assert(time_higher_precision.precision()==DefaultPrecision());
134 next_sample_higher_prec,
135 time_higher_precision,
140 result = result_higher_prec;
142 assert(
Precision(result)==DefaultPrecision());
144 return refinement_success;
151 AMPEndgame(TrackerT
const& new_tracker) : EndgamePrecPolicyBase<TrackerT>(new_tracker)
154 virtual ~AMPEndgame() =
default;
unsigned EnsureAtUniformPrecision(TimeCont< dbl > ×, SampCont< dbl > &samples)
Does not a thing, because cannot.
Definition adaptive_precision_utilities.hpp:114
void NotifyObservers(AnyEvent const &e) const
Sends an Event (more particularly, AnyEvent) to all watching observers of this object.
Definition observable.hpp:90
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:303
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
T max(T const &a, T const &b, T const &c)
Three-argument form of max.
Definition mpfr_extensions.hpp:98