MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ reversal_count()

size_t MayaFlux::Kinesis::reversal_count ( std::span< const double >  samples,
size_t  window 
)
inlinenoexcept

Number of direction reversals across a window.

Parameters
samplesNewest-first span
windowNumber of samples, minimum 3
Returns
Count of sign changes between consecutive non-zero steps

The scalar reading of total_turning: how often the value turned around, not by how much.

Definition at line 878 of file Differential.hpp.

879{
880 window = std::min(window < 3 ? size_t { 3 } : window, samples.size());
881 size_t reversals = 0;
882 double previous = 0.0;
883 for (size_t i = 0; i + 1 < window; ++i) {
884 const double step = samples[i] - samples[i + 1];
885 if (step == 0.0)
886 continue;
887 if (previous != 0.0 && (step > 0.0) != (previous > 0.0))
888 ++reversals;
889 previous = step;
890 }
891 return reversals;
892}
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23

References window.