SpECTRE
v2024.12.16
|
A class that predicts when a function crosses zero. More...
#include <ZeroCrossingPredictor.hpp>
Public Member Functions | |
ZeroCrossingPredictor (size_t min_size, size_t max_size) | |
Uses at most max_size times for the fit; throws away old times as new times are added. The is_valid function returns false until min_size times have been added. min_size must be at least 3. | |
void | add (double t, DataVector data_at_time_t) |
Adds a data point at time t to the ZeroCrossingPredictor. | |
DataVector | zero_crossing_time (double current_time) const |
For each component of the data, returns the time, relative to current_time, that a linear fit to the given component of the data crosses zero. The length of the return value is the same as the length of data_at_time_t in the add function. More... | |
std::optional< double > | min_positive_zero_crossing_time (double current_time) const |
The minimum positive value over the DataVector returned by zero_crossing_time. If there is no minimum positive value (all are negative), returns std::nullopt . Also returns std::nullopt if is_valid() is false. | |
bool | is_valid () const |
Returns whether we have enough data to call zero_crossing_time. | |
void | clear () |
Clears the internal arrays. Used to reset if there is a discontinuous change in the data that should not be fit over. | |
void | pup (PUP::er &p) |
Friends | |
bool | operator== (const ZeroCrossingPredictor &, const ZeroCrossingPredictor &) |
A class that predicts when a function crosses zero.
DataVector intrp::ZeroCrossingPredictor::zero_crossing_time | ( | double | current_time | ) | const |
For each component of the data, returns the time, relative to current_time, that a linear fit to the given component of the data crosses zero. The length of the return value is the same as the length of data_at_time_t
in the add
function.
The zero-crossing time that is computed has error bars associated with it. If the error bars are large enough that it is not clear whether the zero-crossing time is positive or negative, then zero is returned instead of the best-fit zero-crossing time.