IT++ Logo
Public Member Functions | Protected Attributes | List of all members
itpp::Scalar_Quantizer Class Reference

Class for vector quantization. More...

#include <itpp/srccode/vq.h>

Public Member Functions

 Scalar_Quantizer ()
 Default constructor.
 
 Scalar_Quantizer (const char *Name)
 Create a VQ from a VQ file.
 
int encode (double x) const
 Encode.
 
ivec encode (const vec &x) const
 Encode the input vector.
 
double decode (int Index) const
 Decode the index. More...
 
vec decode (const ivec &Index) const
 Decode the indices.
 
double Q (double x) const
 Quantize. More...
 
vec Q (const vec &x) const
 Quantize the input vector.
 
double operator() (double x) const
 Quantize. More...
 
vec operator() (const vec &x) const
 Quantize the input vector. More...
 
void set_levels (const vec &L)
 Initialize the codebook by a matrix. More...
 
vec get_levels () const
 Returns the codebook. More...
 
int size () const
 Returns the size (number of codevectors) of the VQ. More...
 

Protected Attributes

vec Levels
 The vector containing the code book. More...
 
double LatestDist
 The distortion at the latest time a vector was encoded. More...
 

Detailed Description

Class for vector quantization.

The following code illustrates how the quantizer can be initialized from a file and used to quantize a random vector.

Scalar_Quantizer Quantizer;
double x,y;
int i;
Quantizer.load("random.sq");
x=randn();
i=Quantizer.encode(x);
y=Quantizer.decode(i);
Scalar_Quantizer()
Default constructor.
double randn(void)
Generates a random Gaussian (0,1) variable.
Definition: random.h:831

Definition at line 152 of file vq.h.

Member Function Documentation

◆ decode()

double itpp::Scalar_Quantizer::decode ( int  Index) const
inline

Decode the index.

Definition at line 189 of file vq.h.

References Levels.

Referenced by Q().

◆ Q()

double itpp::Scalar_Quantizer::Q ( double  x) const
inline

Quantize.

Definition at line 190 of file vq.h.

References decode(), and encode().

Referenced by operator()().

◆ operator()() [1/2]

double itpp::Scalar_Quantizer::operator() ( double  x) const
inline

Quantize.

Definition at line 191 of file vq.h.

References Q().

◆ operator()() [2/2]

vec itpp::Scalar_Quantizer::operator() ( const vec &  x) const
inline

Quantize the input vector.

Definition at line 192 of file vq.h.

References Q().

◆ set_levels()

void itpp::Scalar_Quantizer::set_levels ( const vec &  L)
inline

Initialize the codebook by a matrix.

Definition at line 193 of file vq.h.

References Levels.

◆ get_levels()

vec itpp::Scalar_Quantizer::get_levels ( ) const
inline

Returns the codebook.

Definition at line 194 of file vq.h.

References Levels.

◆ size()

int itpp::Scalar_Quantizer::size ( ) const
inline

Returns the size (number of codevectors) of the VQ.

Definition at line 188 of file vq.h.

References Levels.

Member Data Documentation

◆ Levels

vec itpp::Scalar_Quantizer::Levels
protected

The vector containing the code book.

Definition at line 183 of file vq.h.

Referenced by decode(), get_levels(), set_levels(), and size().

◆ LatestDist

double itpp::Scalar_Quantizer::LatestDist
protected

The distortion at the latest time a vector was encoded.

Definition at line 185 of file vq.h.


The documentation for this class was generated from the following file:
SourceForge Logo

Generated on Sun Jun 5 2022 21:26:42 for IT++ by Doxygen 1.9.3