TMB Documentation
v1.9.11
|
Period analyzer. More...
#include <compression.hpp>
Public Member Functions | |
period | find_best_period (size_t start) |
Find the best period (highest compression degree) starting from a given index. More... | |
size_t | numrep_period (size_t start, size_t p) |
Find number period replicates. More... | |
bool | test_period (size_t start, size_t p) |
Test period one step ahead. More... | |
Public Attributes | |
size_t | max_period_size |
Test periods up to this size. | |
size_t | min_period_rep |
Ignore periods with too small replicator. | |
Period analyzer.
Finds periodic patterns in sequences, e.g. the operation stack or the operator input sequence. The complexity is linear in the sequence length and in the maximum period size.
Periods with high degree of compression are selected. In the example below the period 1 2 1 2 3
with replicator 3 is preferred over 1 2
with replicator 2.
Definition at line 41 of file compression.hpp.
|
inline |
Find the best period (highest compression degree) starting from a given index.
A period of size p
with replicator r
reduces the full vector representation p*r
to just p
, i.e. relative degree of compression is r
. Starting form start
we thus seek the period with highest replicator. The function tests all periods up to a specified max_period_size
. Note that, once a period p
with replicator r
has been found, it is redundant to test periods shorter than p*r+1
.
Definition at line 87 of file compression.hpp.
|
inline |
Find number period replicates.
Find number of consecutive period replicates starting from a given index start
.
Definition at line 68 of file compression.hpp.
|
inline |
Test period one step ahead.
Tests if all(x[i]==x[i+p])
where i = start + 0:(p-1)
.
Definition at line 56 of file compression.hpp.