|
casacore
|
Lossy encoder for stochastic values. More...
#include <stochasticencoder.h>
Classes | |
| class | Dictionary |
Public Types | |
| typedef unsigned | symbol_t |
| Unsigned integer type used for representing the encoded symbols. | |
| typedef ValueType | value_t |
| Template type used for representing floating point values that are to be encoded. | |
Public Member Functions | |
| StochasticEncoder (size_t quantCount, ValueType stddev, bool gaussianMapping=true) | |
| Construct encoder for given dictionary size and Gaussian stddev. | |
| symbol_t | Encode (ValueType value) const |
| Get the quantized symbol for the given floating point value. | |
| symbol_t | EncodeWithDithering (ValueType value, unsigned ditherValue) const |
| Get the quantized symbol for the given floating point value. | |
| value_t | RightBoundary (symbol_t symbol) const |
| Will return the right boundary of the given symbol. | |
| ValueType | Decode (symbol_t symbol) const |
| Get the centroid value that belongs to the given symbol. | |
| size_t | QuantizationCount () const |
| ValueType | MaxQuantity () const |
| ValueType | MinQuantity () const |
Static Public Member Functions | |
| static StochasticEncoder | StudentTEncoder (size_t quantCount, double nu, double rms) |
| static StochasticEncoder | TruncatedGausEncoder (size_t quantCount, double trunc, double rms) |
| static std::uniform_int_distribution< unsigned > | GetDitherDistribution () |
Private Types | |
| typedef long double | num_t |
Private Member Functions | |
| StochasticEncoder (size_t quantCount) | |
| void | initializeStudentT (double nu, double rms) |
| void | initializeTruncatedGaussian (double truncationValue, double rms) |
Static Private Member Functions | |
| static num_t | cumulative (num_t x) |
| static num_t | invCumulative (num_t c, num_t err=num_t(1e-13)) |
Private Attributes | |
| Dictionary | _encDictionary |
| Dictionary | _decDictionary |
Lossy encoder for stochastic values.
This encoder can encode a numeric value represented by a floating point number (float, double, ...) into an integer value with a given limit. It can be made to be the least-square error quantization for some distributions.
Encoding and decoding have asymetric time complexity / speeds, as decoding is easier than encoding. Decoding is a single indexing into an array, thus extremely fast and with constant time complexity. Encoding is a binary search through the quantizaton values, thus takes O(log quantcount). Typical performance of encoding is 100 MB/s.
If the values are encoded into a number of bits which are not divisible by eight, the BytePacker class can be used to pack the values.
Definition at line 32 of file stochasticencoder.h.
|
private |
Definition at line 248 of file stochasticencoder.h.
| typedef unsigned dyscostman::StochasticEncoder< ValueType >::symbol_t |
Unsigned integer type used for representing the encoded symbols.
Definition at line 62 of file stochasticencoder.h.
| typedef ValueType dyscostman::StochasticEncoder< ValueType >::value_t |
Template type used for representing floating point values that are to be encoded.
Definition at line 68 of file stochasticencoder.h.
| dyscostman::StochasticEncoder< ValueType >::StochasticEncoder | ( | size_t | quantCount, |
| ValueType | stddev, | ||
| bool | gaussianMapping = true ) |
Construct encoder for given dictionary size and Gaussian stddev.
This constructor initializes the lookup table, and is therefore quite slow.
| quantCount | The number of quantization levels, i.e., the dictionary size. Normally this is 2^bitcount. One quantity will be saved for storing non-finite values (NaN and infinites). |
| stddev | The standard deviation of the data. The closer this value is to the real stddev, the more accurate the encoder will be. |
| gaussianMapping | Used for testing with non-gaussian distributions. |
Referenced by StudentTEncoder(), and TruncatedGausEncoder().
|
inlineexplicitprivate |
Definition at line 145 of file stochasticencoder.h.
References _decDictionary, and _encDictionary.
|
staticprivate |
|
inline |
Get the centroid value that belongs to the given symbol.
| symbol | Symbol to be decoded |
Definition at line 136 of file stochasticencoder.h.
References _decDictionary.
|
inline |
Get the quantized symbol for the given floating point value.
This method is implemented with a binary search, so takes O(log N), with N the dictionary size (2^bitcount). Use Decode() on the returned symbol to get the decoded value.
| value | Floating point value to be encoded. |
Definition at line 78 of file stochasticencoder.h.
References _encDictionary, and QuantizationCount().
|
inline |
Get the quantized symbol for the given floating point value.
Dithering is applied, which will cause the average error to converge to zero, assuming the error is uniformly distributed. This method is implemented with a binary search, so takes O(log N), with N the dictionary size (2^bitcount). Use Decode() on the returned symbol to get the decoded value.
| value | Floating point value to be encoded. |
| ditherValue | The dithering value to apply. |
Definition at line 100 of file stochasticencoder.h.
References _decDictionary, and _encDictionary.
|
inlinestatic |
Definition at line 85 of file stochasticencoder.h.
|
private |
Referenced by StudentTEncoder().
|
private |
Referenced by TruncatedGausEncoder().
|
staticprivate |
|
inline |
Definition at line 140 of file stochasticencoder.h.
References _decDictionary.
|
inline |
Definition at line 142 of file stochasticencoder.h.
References _decDictionary.
|
inline |
Definition at line 138 of file stochasticencoder.h.
References _decDictionary.
Referenced by Encode().
|
inline |
Will return the right boundary of the given symbol.
The right boundary is the smallest value that would not be quantized to the given symbol anymore. If no such boundary exists, 0.0 is returned.
Definition at line 124 of file stochasticencoder.h.
References _encDictionary.
|
inlinestatic |
Definition at line 47 of file stochasticencoder.h.
References initializeStudentT(), and StochasticEncoder().
|
inlinestatic |
Definition at line 53 of file stochasticencoder.h.
References initializeTruncatedGaussian(), and StochasticEncoder().
|
private |
Definition at line 254 of file stochasticencoder.h.
Referenced by Decode(), EncodeWithDithering(), MaxQuantity(), MinQuantity(), QuantizationCount(), and StochasticEncoder().
|
private |
Definition at line 253 of file stochasticencoder.h.
Referenced by Encode(), EncodeWithDithering(), RightBoundary(), and StochasticEncoder().