35#include <itpp/itexports.h>
74 vec decode(
int Index)
const;
80 vec operator()(
const vec &x);
112 double latest_distortion();
164 double decode(
int Index)
const;
168 double Q(
double x)
const;
170 vec
Q(
const vec &x)
const;
172 double operator()(
double x)
const;
174 vec operator()(
const vec &x)
const;
176 void set_levels(
const vec &L);
178 vec get_levels()
const;
Automatic naming when saving.
Class for vector quantization.
int size() const
Returns the size (number of codevectors) of the VQ.
ivec encode(const vec &x) const
Encode the input vector.
double LatestDist
The distortion at the latest time a vector was encoded.
int encode(double x) const
Encode.
vec Q(const vec &x) const
Quantize the input vector.
void set_levels(const vec &L)
Initialize the codebook by a matrix.
double Q(double x) const
Quantize.
double decode(int Index) const
Decode the index.
vec decode(const ivec &Index) const
Decode the indices.
Scalar_Quantizer(const char *Name)
Create a VQ from a VQ file.
vec Levels
The vector containing the code book.
double operator()(double x) const
Quantize.
Scalar_Quantizer()
Default constructor.
vec get_levels() const
Returns the codebook.
void sort(Vec< T > &data, SORTING_METHOD method=INTROSORT)
Sort the data vector in increasing order.
Class for vector quantization.
void modify_codevector(int no, double mul, const vec &add)
Rescale and translate a codevector.
int dim() const
Returns the dimension of the VQ.
Array< vec > decode(const ivec &Index) const
Decode the indices.
vec operator()(const vec &x)
Quantize the input vector.
vec get_codevector(int Index) const
Returns the codevector at the given index.
int nobits() const
Returns the number of bits of the VQ [log2(size)/dim].
vec decode(int Index) const
Decode the index.
void set_codebook(const mat &CB)
Initialize the codebook by a matrix.
int encode(const vec &x)
Encode the input vector.
ivec encode(const vec &x, int num)
Encode the input vector, and return the num best indices.
vec Q(const vec &x)
Quantize the input vector.
void set_codevector(int Index, const vec &indata)
Set a codevector in the codebook.
int Size
The size of the code book.
void load(const char *Name)
Load the codebook from a file.
double latest_distortion()
Returns the distortion at the latest time a vector was encoded.
void save(const char *Name) const
Save the codebook to a file.
Vector_Quantizer(const char *Name)
Create a VQ from a VQ file.
mat get_codebook() const
Returns the codebook.
Vector_Quantizer()
Default constructor.
int size() const
Returns the size (number of codevectors) of the VQ.
vec CodeBook
The vector containing the code book.
double LatestDist
The distortion at the latest time a vector was encoded.
int Dim
The dimension of the code book.
int levels2bits(int n)
Calculate the number of bits needed to represent n different values (levels).
int size(const Vec< T > &v)
Length of vector.
Logarithmic and exponenential functions - header file.
ITPP_EXPORT int scalar_encode(double x, vec &Levels)
ADD DOCUMENTATION HERE.
double scalar_quantize(double x, vec &Levels)
ADD DOCUMENTATION HERE.
Templated Vector Class Definitions.