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

◆ compute_power_energy()

std::vector< double > MayaFlux::Yantra::compute_power_energy ( std::span< const double >  data,
const size_t  num_windows,
const uint32_t  m_hop_size,
const uint32_t  m_window_size 
)

Compute power energy using zero-copy processing.

This function computes the power energy for a given data span. It calculates the sum of squares of samples in each window.

Parameters
dataInput data span
num_windowsNumber of windows to process
m_hop_sizeHop size for windowing
m_window_sizeSize of each window
Returns
Vector of power energy values

Definition at line 66 of file AnalysisHelper.cpp.

67{
68 std::vector<double> power_values(num_windows);
69
70 std::vector<size_t> indices(num_windows);
71 std::iota(indices.begin(), indices.end(), 0);
72
73 std::for_each(std::execution::par_unseq, indices.begin(), indices.end(),
74 [&](size_t i) {
75 const size_t start_idx = i * hop_size;
76 const size_t end_idx = std::min(start_idx + window_size, data.size());
77 auto window = data.subspan(start_idx, end_idx - start_idx);
78
79 double sum_squares = 0.0;
80 for (double sample : window) {
81 sum_squares += sample * sample;
82 }
83 power_values[i] = sum_squares;
84 });
85
86 return power_values;
87}

References compute_power_energy().

Referenced by MayaFlux::Yantra::EnergyAnalyzer< InputType, OutputType >::compute_energy_values(), and compute_power_energy().

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