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

◆ zero_crossing_positions()

std::vector< size_t > MayaFlux::Kinesis::Discrete::zero_crossing_positions ( std::span< const double >  data,
double  threshold = 0.0 
)

Sample indices of zero crossings in the full span.

Note
Produces sparse output; not vectorisable or suitable for compute kernels.
Parameters
dataInput span
thresholdCrossing threshold (default: 0.0)
Returns
Sorted sample indices where sign changes occur

Definition at line 634 of file Analysis.cpp.

635{
636 std::vector<size_t> pos;
637 pos.reserve(data.size() / 4);
638 for (size_t i = 1; i < data.size(); ++i) {
639 if ((data[i] >= threshold) != (data[i - 1] >= threshold))
640 pos.push_back(i);
641 }
642 pos.shrink_to_fit();
643 return pos;
644}

References zero_crossing_positions().

Referenced by MayaFlux::Yantra::extract_zero_crossings(), and zero_crossing_positions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: