|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Rows-by-columns table of doubles with atomic cell access. More...
#include <Weights.hpp>
Collaboration diagram for MayaFlux::Kinesis::Stochastic::Weights:Classes | |
| class | Cell |
| Proxy for one cell with atomic load and store. More... | |
Public Member Functions | |
| void | apply_edges (std::span< const std::pair< size_t, size_t > > edges, double weight=1.0, bool symmetric=true, bool normalize=true) noexcept |
| Write an adjacency edge list into this table. | |
| void | assign (size_t rows, size_t cols, double initial=0.0) |
| Replace dimensions and reset every cell. | |
| size_t | cols () const noexcept |
| void | fill (double value) noexcept |
| double | get (size_t row, size_t col) const noexcept |
| Atomic read of one cell. | |
| void | normalize_row (size_t row) noexcept |
| Scale a row so its cells sum to one. | |
| Cell | operator() (size_t row, size_t col) noexcept |
| Access one cell. | |
| Weights & | operator= (std::initializer_list< std::initializer_list< double > > values) |
| Assign every cell from nested initializer lists. | |
| std::span< const double > | row (size_t row) const noexcept |
| Non-atomic view of one row. | |
| size_t | rows () const noexcept |
| void | scale_row (size_t row, double factor) noexcept |
| void | uniform_excluding_self () noexcept |
| Every cell uniform except the diagonal, each row normalized to sum to one. | |
| size_t | weighted_pick (size_t row_index, Stochastic &generator) const |
| Weighted random draw over one row of this table. | |
| Weights ()=default | |
| Weights (size_t rows, size_t cols, double initial=0.0) | |
Static Public Member Functions | |
| static size_t | weighted_pick (std::span< const double > weights, Stochastic &generator) |
| Weighted random draw over a row of nonnegative weights. | |
Private Attributes | |
| size_t | m_cols {} |
| std::vector< double > | m_data |
| size_t | m_rows {} |
Rows-by-columns table of doubles with atomic cell access.
A plain numeric table with no knowledge of what its rows and columns mean. Transition probabilities, source-to-output weights, and neighbour strengths are the same structure read by different code.
Cells are read and written with relaxed atomics, so any thread can write a cell while another reads it. Row helpers and row views are not atomic and belong on the thread that consumes the table. Copying is not synchronised. Dimensions change only through assign(), which must not run concurrently with any other access.
weighted_pick() turns a row into a single stochastic choice, drawing from a Stochastic instance the caller supplies and owns (one instance per thread, matching Stochastic's own contract).
Definition at line 36 of file Weights.hpp.