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

◆ dominant_cell()

template<typename LatticeT , typename CellT >
std::pair< CellT, size_t > MayaFlux::Kinesis::SymbolicTrajectory< LatticeT, CellT >::dominant_cell ( size_t  window) const
inline

Cell with the most observations within the most recent window observations.

Parameters
windowNumber of recent observations to examine, clamped to the trajectory's retained history capacity
Returns
The most-occupied cell in the window, and how many of the window's observations fell in it

Ties resolve to whichever qualifying cell appears first in the scan, which is the most recent one among ties since the underlying HistoryBuffer is newest-first; not documented as a guarantee beyond "deterministic," since which specific tie-break rule matters is a caller decision this does not presume to make.

Definition at line 180 of file SymbolicTrajectory.hpp.

181 {
182 window = std::min(window, m_history.capacity());
183 const auto view = m_history.linearized_view();
184
185 CellT best {};
186 size_t best_count = 0;
187 for (size_t i = 0; i < window; ++i) {
188 size_t count = 0;
189 for (size_t j = 0; j < window; ++j) {
190 if (view[j] == view[i])
191 ++count;
192 }
193 if (count > best_count) {
194 best_count = count;
195 best = view[i];
196 }
197 }
198 return { best, best_count };
199 }
size_t count
Memory::HistoryBuffer< CellT > m_history
std::span< T > linearized_view()
Get mutable linearized view of entire history.
size_t capacity() const
Get buffer capacity.

References MayaFlux::Memory::HistoryBuffer< T >::capacity(), count, MayaFlux::Memory::HistoryBuffer< T >::linearized_view(), and MayaFlux::Kinesis::SymbolicTrajectory< LatticeT, CellT >::m_history.

+ Here is the call graph for this function: