Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
events.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//events.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//events.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 events.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
29
30#pragma once
33
34namespace bertini {
35
36 namespace tracking{
37
38
39
44
48 ADD_BERTINI_EVENT_TYPE(SuccessfulStep,TrackingEvent);
49
53 ADD_BERTINI_EVENT_TYPE(FailedStep,TrackingEvent);
54
58 ADD_BERTINI_EVENT_TYPE(NewStep,TrackingEvent);
59
66
70 template<class ObservedT, typename NumT>
71 class SuccessfulPredict : public TrackingEvent<ObservedT>
72 { BOOST_TYPE_INDEX_REGISTER_CLASS
73 public:
80 SuccessfulPredict(const ObservedT & obs,
81 Vec<NumT> const& resulting_point) : TrackingEvent<ObservedT>(obs),
82 resulting_point_(resulting_point)
83 {}
84
85
86 virtual ~SuccessfulPredict() = default;
88
92 const Vec<NumT>& ResultingPoint() const {return resulting_point_;}
93 private:
94 const Vec<NumT>& resulting_point_;
95 };
96
100 template<class ObservedT, typename NumT>
101 class SuccessfulCorrect : public TrackingEvent<ObservedT>
102 { BOOST_TYPE_INDEX_REGISTER_CLASS
103 public:
110 SuccessfulCorrect(const ObservedT & obs,
111 Vec<NumT> const& resulting_point) : TrackingEvent<ObservedT>(obs),
112 resulting_point_(resulting_point)
113 {}
114
115
116 virtual ~SuccessfulCorrect() = default;
118
122 const Vec<NumT>& ResultingPoint() const {return resulting_point_;}
123 private:
124 const Vec<NumT>& resulting_point_;
125 };
126
128 //
129 // Precision events
130
134 ADD_BERTINI_EVENT_TYPE(PrecisionEvent,TrackingEvent);
135
137 template<class ObservedT>
138 class PrecisionChanged : public PrecisionEvent<ObservedT>
139 { BOOST_TYPE_INDEX_REGISTER_CLASS
140 public:
148 PrecisionChanged(const ObservedT & obs,
149 unsigned previous, unsigned next) : PrecisionEvent<ObservedT>(obs),
150 prev_(previous),
151 next_(next)
152 {}
153
154
155 virtual ~PrecisionChanged() = default;
157
161 auto Previous() const {return prev_;}
162
166 auto Next() const {return next_;}
167 private:
168 const unsigned prev_, next_;
169 };
170
174 template<class ObservedT>
175 class PrecisionIncreased : public PrecisionChanged<ObservedT>
176 { BOOST_TYPE_INDEX_REGISTER_CLASS
177 public:
185 PrecisionIncreased(const ObservedT & obs,
186 unsigned previous, unsigned next) : PrecisionChanged<ObservedT>(obs, previous, next)
187 {}
188 virtual ~PrecisionIncreased() = default;
190 };
191
195 template<class ObservedT>
196 class PrecisionDecreased : public PrecisionChanged<ObservedT>
197 { BOOST_TYPE_INDEX_REGISTER_CLASS
198 public:
206 PrecisionDecreased(const ObservedT & obs,
207 unsigned previous, unsigned next) : PrecisionChanged<ObservedT>(obs, previous, next)
208 {}
209 virtual ~PrecisionDecreased() = default;
211 };
212
217
221 ADD_BERTINI_EVENT_TYPE(PredictorHigherPrecisionNecessary,HigherPrecisionNecessary);
222
226 ADD_BERTINI_EVENT_TYPE(CorrectorHigherPrecisionNecessary,HigherPrecisionNecessary);
227
232
236 ADD_BERTINI_EVENT_TYPE(PredictorMatrixSolveFailure,MatrixSolveFailure);
237
241 ADD_BERTINI_EVENT_TYPE(FirstStepPredictorMatrixSolveFailure,MatrixSolveFailure);
242
246 ADD_BERTINI_EVENT_TYPE(CorrectorMatrixSolveFailure,MatrixSolveFailure);
248 //
249 // Stepsize events
250
254 ADD_BERTINI_EVENT_TYPE(StepsizeEvent,TrackingEvent);
255
261 ADD_BERTINI_EVENT_TYPE(StepsizeDecreased,StepsizeEvent);
262
268 ADD_BERTINI_EVENT_TYPE(StepsizeIncreased,StepsizeEvent);
269
270
272 //
273 // beginning and end events
274
278 ADD_BERTINI_EVENT_TYPE(TrackingStarted,TrackingEvent);
279
283 ADD_BERTINI_EVENT_TYPE(TrackingEnded, TrackingEvent);
284
288 ADD_BERTINI_EVENT_TYPE(InfinitePathTruncation, TrackingEvent);
289
293 template<class ObservedT, typename NumT>
294 class Initializing : public TrackingEvent<ObservedT>
295 { BOOST_TYPE_INDEX_REGISTER_CLASS
296 public:
297
306 Initializing(const ObservedT & obs,
307 NumT const& start_time,
308 NumT const& endtime,
309 Vec<NumT> const& start_point) : TrackingEvent<ObservedT>(obs),
310 start_time_(start_time),
311 end_time_(endtime),
312 start_point_(start_point)
313 {}
314
315
316 virtual ~Initializing() = default;
317 Initializing() = delete;
318
322 const NumT& StartTime() const {return start_time_;}
323
327 const NumT& EndTime() const {return end_time_;}
328
332 const Vec<NumT>& StartPoint() const {return start_point_;}
333 private:
334 const NumT& start_time_;
335 const NumT& end_time_;
336 const Vec<NumT>& start_point_;
337 };
338}// re: namespace tracking
339}// re: namespace bertini
Initializing(const ObservedT &obs, NumT const &start_time, NumT const &endtime, Vec< NumT > const &start_point)
Constructor for an Initializing Event.
Definition events.hpp:306
const NumT & EndTime() const
Get the target time for tracking.
Definition events.hpp:327
virtual ~Initializing()=default
const NumT & StartTime() const
Get the time (tracking wise, not clock wise) at which tracking is starting/.
Definition events.hpp:322
const Vec< NumT > & StartPoint() const
Get the start point, the input point for TrackPath.
Definition events.hpp:332
PrecisionChanged(const ObservedT &obs, unsigned previous, unsigned next)
The constructor for a PrecisionChanged Event.
Definition events.hpp:148
auto Next() const
Get the next precision, what it changed to.
Definition events.hpp:166
auto Previous() const
Get the previous precision.
Definition events.hpp:161
PrecisionDecreased(const ObservedT &obs, unsigned previous, unsigned next)
The constructor for a PrecisionDecreased Event.
Definition events.hpp:206
PrecisionIncreased(const ObservedT &obs, unsigned previous, unsigned next)
The constructor for a PrecisionIncreased Event.
Definition events.hpp:185
SuccessfulCorrect(const ObservedT &obs, Vec< NumT > const &resulting_point)
The constructor for a SuccessfulCorrect Event.
Definition events.hpp:110
const Vec< NumT > & ResultingPoint() const
Get the resulting point of the correction.
Definition events.hpp:122
SuccessfulPredict(const ObservedT &obs, Vec< NumT > const &resulting_point)
The constructor for a SuccessfulPredict Event.
Definition events.hpp:80
const Vec< NumT > & ResultingPoint() const
Get the resulting point of the prediction.
Definition events.hpp:92
Contains the detail/events base types.
#define ADD_BERTINI_EVENT_TYPE(event_name, event_parenttype)
Defines a new event type in a hierarchy.
Definition events.hpp:166
Bertini extensions of the Eigen linear algebra library.
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
Event< ObsT, true > ConstEvent
An event holding a const reference to its observable.
Definition events.hpp:154
@ MatrixSolveFailure
Definition config.hpp:56
@ HigherPrecisionNecessary
Definition config.hpp:52
@ SingularStartPoint
Definition config.hpp:62