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