Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
itpp
srccode
vq.h
Go to the documentation of this file.
1
29
#ifndef VQ_H
30
#define VQ_H
31
32
#include <
itpp/base/vec.h
>
33
#include <
itpp/base/sort.h
>
34
#include <
itpp/base/math/log_exp.h
>
35
36
namespace
itpp
37
{
38
39
62
class
Vector_Quantizer
63
{
64
public
:
66
Vector_Quantizer
();
68
Vector_Quantizer
(
const
char
*
Name
);
70
int
encode
(
const
vec &x);
72
ivec
encode
(
const
vec &x,
int
num);
74
vec
decode
(
int
Index)
const
;
76
Array<vec>
decode
(
const
ivec &Index)
const
;
78
vec
Q
(
const
vec &x);
80
vec
operator()
(
const
vec &x);
82
void
set_codebook
(
const
mat &CB);
84
mat
get_codebook
()
const
;
86
void
set_codevector
(
int
Index,
const
vec &indata);
88
vec
get_codevector
(
int
Index)
const
;
90
void
modify_codevector
(
int
no,
double
mul,
const
vec &add);
92
int
size
()
const
;
94
int
dim
()
const
;
96
int
nobits
()
const
;
103
void
load
(
const
char
*Name);
110
void
save
(
const
char
*Name)
const
;
112
double
latest_distortion
();
113
protected
:
115
vec
CodeBook
;
117
int
Size
;
119
int
Dim
;
121
double
LatestDist
;
122
};
123
124
// INLINE FUNCTIONS
125
126
inline
int
Vector_Quantizer::size
()
const
{
return
Size
; }
127
inline
int
Vector_Quantizer::nobits
()
const
{
return
levels2bits
(
Size
); }
128
inline
int
Vector_Quantizer::dim
()
const
{
return
Dim
; }
129
inline
double
Vector_Quantizer::latest_distortion
() {
return
LatestDist
; }
130
inline
vec
Vector_Quantizer::decode
(
int
Index)
const
{
return
get_codevector
(Index); }
131
inline
vec
Vector_Quantizer::Q
(
const
vec &x) {
return
decode
(
encode
(x)); }
132
inline
vec
Vector_Quantizer::operator()
(
const
vec &x) {
return
Q
(x); }
133
152
class
Scalar_Quantizer
153
{
154
public
:
156
Scalar_Quantizer
();
158
Scalar_Quantizer
(
const
char
*
Name
);
160
int
encode
(
double
x)
const
;
162
ivec
encode
(
const
vec &x)
const
;
164
double
decode
(
int
Index)
const
;
166
vec
decode
(
const
ivec &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
;
180
int
size
()
const
;
181
protected
:
183
vec
Levels
;
185
double
LatestDist
;
186
};
187
188
inline
int
Scalar_Quantizer::size
()
const
{
return
Levels
.length(); }
189
inline
double
Scalar_Quantizer::decode
(
int
Index)
const
{
return
Levels
(Index); }
190
inline
double
Scalar_Quantizer::Q
(
double
x)
const
{
return
decode
(
encode
(x)); }
191
inline
double
Scalar_Quantizer::operator()
(
double
x)
const
{
return
Q
(x); }
192
inline
vec
Scalar_Quantizer::operator()
(
const
vec &x)
const
{
return
Q
(x); }
193
inline
void
Scalar_Quantizer::set_levels
(
const
vec &L) {
Levels
= L;sort(
Levels
); }
194
inline
vec
Scalar_Quantizer::get_levels
()
const
{
return
Levels
; }
195
197
int
scalar_encode
(
double
x, vec &Levels) ;
199
ivec
scalar_encode
(vec &x, vec &Levels);
201
inline
double
scalar_quantize
(
double
x, vec &Levels) {
return
Levels(
scalar_encode
(x, Levels)); }
203
inline
vec
scalar_quantize
(vec &x, vec &Levels) {
return
Levels(
scalar_encode
(x, Levels)); }
204
205
206
}
// namespace itpp
207
208
#endif // #ifndef VQ_H
Generated on Fri Mar 21 2014 17:14:14 for IT++ by
Doxygen
1.8.1.2