StochHMM
v0.34
Flexible Hidden Markov Model C++ Library and Application
|
#include <stochTable.h>
Classes | |
struct | stoch_value |
Public Member Functions | |
stochTable (size_t) | |
~stochTable () | |
void | push (size_t pos, size_t st, size_t st_to, float val) |
std::string | stringify () |
Stringify the stochTable. | |
void | print () |
Prints the stochTable to stdout. | |
void | finalize () |
size_t | get_state_position (size_t pos, uint16_t) |
void | traceback (traceback_path &path) |
Private Attributes | |
size_t | last_position |
std::vector< stoch_value > * | state_val |
std::vector< size_t > * | position |
Stochastic table stores stochastic values in a vector. Data structure is implemented to reduce the memory that would be needed if we allocated a 2D table with all the transitions. This lookup table is 1D and only stores those values which we add. Each the value are stores (Current state, Previous State, Score as P(X)). In addition, the indices of each state and position are recorded so that they can be referenced quickly. So the memory size necessary to store the values for a sparsely connected model are greatly reduce. However, the time to recreate the table is increased because it doesn't allocate the memory up front, but rather pushes values as they are recorded.
Definition at line 34 of file stochTable.h.
StochHMM::stochTable::stochTable | ( | size_t | seq_size | ) |
stochTable constructor
[in] | seq_size | Size of sequence |
Definition at line 15 of file stochTable.cpp.
References last_position, position, and state_val.
StochHMM::stochTable::~stochTable | ( | ) |
void StochHMM::stochTable::finalize | ( | ) |
Finalized stochTable Normalizes the traceback pointer values and calculates the previous cell iterator within the previous position segment. This speeds up the the referencing necessary for tracebacks across the traceback table.
Definition at line 59 of file stochTable.cpp.
References StochHMM::addLog(), get_state_position(), last_position, position, SIZE_MAX, and state_val.
Referenced by StochHMM::trellis::naive_stochastic_forward(), StochHMM::trellis::naive_stochastic_viterbi(), StochHMM::trellis::simple_stochastic_forward(), and StochHMM::trellis::simple_stochastic_viterbi().
size_t StochHMM::stochTable::get_state_position | ( | size_t | pos, |
uint16_t | state | ||
) |
Returns the states iterator position within the array
pos | Position within the sequence |
state | Iterator of state that you want |
Definition at line 141 of file stochTable.cpp.
References position, state_val, and UINT16_MAX.
Referenced by finalize().
void StochHMM::stochTable::print | ( | ) |
Prints the stochTable to stdout.
Definition at line 153 of file stochTable.cpp.
References stringify().
void StochHMM::stochTable::push | ( | size_t | pos, |
size_t | st, | ||
size_t | st_to, | ||
float | value | ||
) |
Pushes the information for traceback pointer onto the table
pos | Position of current traceback pointer in sequence |
st | Current State |
st_to | Previous State |
value | Unnormalized value of traceback pointer |
Definition at line 46 of file stochTable.cpp.
References last_position, and state_val.
Referenced by StochHMM::trellis::naive_stochastic_forward(), StochHMM::trellis::naive_stochastic_viterbi(), StochHMM::trellis::simple_stochastic_forward(), and StochHMM::trellis::simple_stochastic_viterbi().
std::string StochHMM::stochTable::stringify | ( | ) |
Stringify the stochTable.
Definition at line 159 of file stochTable.cpp.
References last_position, and position.
Referenced by print().
void StochHMM::stochTable::traceback | ( | traceback_path & | path | ) |
Traceback through the table using the traceback probabilities
[out] | path | Reference to traceback_path |
Definition at line 177 of file stochTable.cpp.
References position, StochHMM::traceback_path::push_back(), SIZE_MAX, and UINT16_MAX.
Referenced by StochHMM::trellis::stochastic_traceback().
|
private |
Definition at line 63 of file stochTable.h.
Referenced by finalize(), push(), stochTable(), and stringify().
|
private |
Definition at line 65 of file stochTable.h.
Referenced by finalize(), get_state_position(), stochTable(), stringify(), traceback(), and ~stochTable().
|
private |
Definition at line 64 of file stochTable.h.
Referenced by finalize(), get_state_position(), push(), stochTable(), and ~stochTable().