1 #ifndef DYSCO_STOCHASTIC_ENCODER_H
2 #define DYSCO_STOCHASTIC_ENCODER_H
10 namespace dyscostman {
31 template <
typename ValueType =
float>
46 bool gaussianMapping =
true);
89 return std::uniform_int_distribution<unsigned>(0, ((1u << 31) - 1));
114 ValueType ditherMark =
115 ValueType(1u << 31) * (value - leftValue) / (rightValue - leftValue);
116 if (ditherMark > ditherValue)
184 size_t m = (p + q) / 2;
190 size_t m = (p + q) / 2;
212 size_t m = (p + q) / 2;
232 const value_t *m = p + (q - p) / 2;
value_t smallest_value() const
const_iterator lower_bound_fast(value_t val) const
Returns an iterator pointing to the first element in the dictionary that is not less than (i...
Tp & front() noexcept
Get reference to first element in container.
const_iterator lower_bound(value_t val) const
Returns an iterator pointing to the first element in the dictionary that is not less than (i...
static num_t invCumulative(num_t c, num_t err=num_t(1e-13))
value_t RightBoundary(symbol_t symbol) const
Will return the right boundary of the given symbol.
ValueType MaxQuantity() const
const value_t * const_iterator
symbol_t EncodeWithDithering(ValueType value, unsigned ditherValue) const
Get the quantized symbol for the given floating point value.
void resize(size_t n)
Change the number of elements in the container.
void reserve(size_t size)
iterator begin() noexcept
Get iterator to first element.
const_iterator end() const
static StochasticEncoder StudentTEncoder(size_t quantCount, double nu, double rms)
ValueType Decode(symbol_t symbol) const
Get the centroid value that belongs to the given symbol.
bool isfinite(const std::complex< T > &val)
value_t value(const_iterator iter) const
ValueType MinQuantity() const
size_t capacity() const noexcept
Get the number of elements the container can currently hold without reallocating storage.
const_iterator lower_bound_slow(value_t val) const
Below is the first failed result of an attempt to beat the STL in performance.
iterator end() noexcept
Get iterator to element past last element.
StochasticEncoder(size_t quantCount)
unsigned symbol_t
Unsigned integer type used for representing the encoded symbols.
void reserve(size_t n)
Reserve space for a number of elements, to prevent the overhead of extra reallocations.
symbol_t symbol(const_iterator iter) const
Tp & back() noexcept
Get reference to last element in container.
LatticeExprNode stddev(const LatticeExprNode &expr)
void initializeTruncatedGaussian(double truncationValue, double rms)
symbol_t largest_symbol() const
Header file for uvector and its relational and swap functions.
static num_t cumulative(num_t x)
value_t largest_value() const
static std::uniform_int_distribution< unsigned > GetDitherDistribution()
const_iterator begin() const
void initializeStudentT(double nu, double rms)
StochasticEncoder(size_t quantCount, ValueType stddev, bool gaussianMapping=true)
Construct encoder for given dictionary size and Gaussian stddev.
const Double e
e and functions thereof:
Dictionary _encDictionary
TableExprNode rms(const TableExprNode &array)
const Double c
Fundamental physical constants (SI units):
value_t value(symbol_t sym) const
size_t QuantizationCount() const
Lossy encoder for stochastic values.
ao::uvector< value_t > _values
ValueType value_t
Template type used for representing floating point values that are to be encoded. ...
static StochasticEncoder TruncatedGausEncoder(size_t quantCount, double trunc, double rms)
Dictionary _decDictionary
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
symbol_t Encode(ValueType value) const
Get the quantized symbol for the given floating point value.
size_t size() const noexcept
Get number of elements in container.
size_t capacity(size_t) const