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

◆ pattern_lookup()

MAYAFLUX_API double MayaFlux::Kinesis::Discrete::pattern_lookup ( std::span< const double >  window,
std::span< const double >  coefs 
)
noexcept

Table indexed by the recent shape of the window.

coefs: [levels, count, lo, hi, table...]. The newest count values are each quantised to one of levels cells over [lo, hi] (Lattice1D), combined into an index with the newest value as the lowest digit, and the table of levels^count entries is read there. Values outside [lo, hi] fall in the edge cells and missing values count as zero. A table too small for the index range, or hi not above lo, gives zero.

Definition at line 341 of file Kernels.cpp.

342{
343 if (coefs.size() < 5 || !(coefs[3] > coefs[2]))
344 return 0.0;
345
346 const auto levels = static_cast<uint32_t>(std::max(coefs[0], 1.0));
347 const auto count = static_cast<size_t>(std::max(coefs[1], 1.0));
348 const auto table = coefs.subspan(4);
349
350 size_t total = 1;
351 for (size_t i = 0; i < count; ++i) {
352 if (total > table.size() / levels)
353 return 0.0;
354 total *= levels;
355 }
356
357 const Lattice1D lattice { .resolution = levels, .bounds = { .min = coefs[2], .max = coefs[3] } };
358
359 size_t index = 0;
360 size_t stride = 1;
361 for (size_t i = 0; i < count; ++i) {
362 const double value = i < window.size() ? window[i] : 0.0;
363 index += static_cast<size_t>(lattice.cell_at(value)) * stride;
364 stride *= levels;
365 }
366 return table[index];
367}
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
uint32_t total
glm::vec3 value
uint32_t index
Definition VKDevice.cpp:122
size_t count
uint32_t resolution
Cell count. Zero is invalid.
Definition Lattice.hpp:228
A regular subdivision of an AABB1D into a number of cells.
Definition Lattice.hpp:227

References count, index, MayaFlux::Kinesis::Lattice1D::resolution, total, value, and window.