IT++
4.3.1
Toggle main menu visibility
itpp
comm
llr.h
Go to the documentation of this file.
1
28
29
#ifndef LLR_H
30
#define LLR_H
31
32
#include <limits>
33
#include <
itpp/base/vec.h
>
34
#include <
itpp/base/mat.h
>
35
#include <
itpp/base/specmat.h
>
36
#include <
itpp/base/matfunc.h
>
37
#include <limits>
38
#include <itpp/itexports.h>
39
40
namespace
itpp
41
{
42
46
typedef
signed
int
QLLR
;
47
51
typedef
Vec<QLLR>
QLLRvec
;
52
56
typedef
Mat<QLLR>
QLLRmat
;
57
61
const
QLLR
QLLR_MAX
= (std::numeric_limits<QLLR>::max() >> 4);
62
// added some margin to make sure the sum of two LLR is still permissible
63
124
class
ITPP_EXPORT
LLR_calc_unit
125
{
126
public
:
128
LLR_calc_unit
();
129
135
LLR_calc_unit
(
short
int
Dint1,
short
int
Dint2,
short
int
Dint3);
136
165
void
init_llr_tables
(
short
int
Dint1 = 12,
short
int
Dint2 = 300,
166
short
int
Dint3 = 7);
167
169
QLLR
to_qllr
(
double
l)
const
;
170
172
QLLRvec
to_qllr
(
const
vec &l)
const
;
173
175
QLLRmat
to_qllr
(
const
mat &l)
const
;
176
178
double
to_double
(
QLLR
l)
const
;
179
181
vec
to_double
(
const
QLLRvec
&l)
const
;
182
184
mat
to_double
(
const
QLLRmat
&l)
const
;
185
191
inline
QLLR
jaclog
(
QLLR
a,
QLLR
b)
const
;
192
// Note: a version of this function taking "double" values as input
193
// is deliberately omitted, because this is rather slow.
194
203
QLLR
Boxplus
(
QLLR
a,
QLLR
b)
const
;
204
210
inline
QLLR
logexp
(
QLLR
x)
const
;
211
213
ivec
get_Dint
();
214
216
friend
ITPP_EXPORT std::ostream &
operator<<
(std::ostream &os,
const
LLR_calc_unit
&l);
217
218
private
:
220
ivec construct_logexp_table();
221
223
ivec logexp_table;
224
226
short
int
Dint1, Dint2, Dint3;
227
};
228
233
ITPP_EXPORT std::ostream &
operator<<
(std::ostream &os,
const
LLR_calc_unit
&lcu);
234
235
236
// ----------------------------------------------------------------------
237
// implementation of some inline functions
238
// ----------------------------------------------------------------------
239
240
inline
double
LLR_calc_unit::to_double
(
QLLR
l)
const
241
{
242
return
static_cast<
double
>
(l) / (1 << Dint1);
243
}
244
245
inline
QLLR
LLR_calc_unit::to_qllr
(
double
l)
const
246
{
247
double
QLLR_MAX_double =
to_double
(
QLLR_MAX
);
248
// Don't abort when overflow occurs, just saturate the QLLR
249
if
(l > QLLR_MAX_double) {
250
it_info_debug
(
"LLR_calc_unit::to_qllr(): LLR overflow"
);
251
return
QLLR_MAX
;
252
}
253
if
(l < -QLLR_MAX_double) {
254
it_info_debug
(
"LLR_calc_unit::to_qllr(): LLR overflow"
);
255
return
-
QLLR_MAX
;
256
}
257
return
static_cast<
QLLR
>
(std::floor(0.5 + (1 << Dint1) * l));
258
}
259
260
261
inline
QLLR
LLR_calc_unit::logexp
(
QLLR
x)
const
262
{
263
it_assert_debug
(x >= 0,
"LLR_calc_unit::logexp(): Wrong LLR value"
);
264
int
ind = x >> Dint3;
265
if
(ind >= Dint2)
// outside table
266
return
0;
267
268
it_assert_debug
(ind >= 0,
"LLR_calc_unit::logexp(): Internal error"
);
269
it_assert_debug
(ind < Dint2,
"LLR_calc_unit::logexp(): internal error"
);
270
271
// With interpolation
272
// int delta=x-(ind<<Dint3);
273
// return ((delta*logexp_table(ind+1) + ((1<<Dint3)-delta)*logexp_table(ind)) >> Dint3);
274
275
// Without interpolation
276
return
logexp_table(ind);
277
}
278
279
280
inline
QLLR
LLR_calc_unit::jaclog
(
QLLR
a,
QLLR
b)
const
281
{
282
QLLR
x, maxab;
283
284
if
(a > b) {
285
maxab = a;
286
x = a - b;
287
}
288
else
{
289
maxab = b;
290
x = b - a;
291
}
292
293
if
(maxab >=
QLLR_MAX
)
294
return
QLLR_MAX
;
295
else
296
return
(maxab +
logexp
(x));
297
}
298
299
}
300
301
#endif
itpp::LLR_calc_unit
Log-likelihood algebra calculation unit.
Definition
llr.h:125
itpp::LLR_calc_unit::QLLR
signed int QLLR
Definition
llr.h:46
itpp::LLR_calc_unit::jaclog
QLLR jaclog(QLLR a, QLLR b) const
Jacobian logarithm.
Definition
llr.h:280
itpp::LLR_calc_unit::Boxplus
QLLR Boxplus(QLLR a, QLLR b) const
Hagenauer's "Boxplus" operator.
Definition
llr.cpp:123
itpp::LLR_calc_unit::init_llr_tables
void init_llr_tables(short int Dint1=12, short int Dint2=300, short int Dint3=7)
Set the quantization and table parameters.
Definition
llr.cpp:55
itpp::LLR_calc_unit::get_Dint
ivec get_Dint()
Retrieve the table resolution values.
Definition
llr.cpp:46
itpp::LLR_calc_unit::to_qllr
QLLR to_qllr(double l) const
Convert a "real" LLR value to an LLR type.
Definition
llr.h:245
itpp::LLR_calc_unit::QLLRmat
Mat< QLLR > QLLRmat
Definition
llr.h:56
itpp::LLR_calc_unit::operator<<
friend ITPP_EXPORT std::ostream & operator<<(std::ostream &os, const LLR_calc_unit &l)
Print some properties of the LLR calculation unit in plain text.
Definition
llr.cpp:162
itpp::LLR_calc_unit::logexp
QLLR logexp(QLLR x) const
Logexp operator.
Definition
llr.h:261
itpp::LLR_calc_unit::to_double
double to_double(QLLR l) const
Convert an LLR type to a "real" LLR.
Definition
llr.h:240
itpp::LLR_calc_unit::LLR_calc_unit
LLR_calc_unit()
Constructor, using the default table resolution.
Definition
llr.cpp:36
itpp::LLR_calc_unit::QLLR_MAX
const QLLR QLLR_MAX
Definition
llr.h:61
itpp::LLR_calc_unit::QLLRvec
Vec< QLLR > QLLRvec
Definition
llr.h:51
itpp::Mat
Matrix Class (Templated).
Definition
mat.h:202
itpp::Vec
Vector Class (Templated).
Definition
vec.h:245
it_info_debug
#define it_info_debug(s)
Print information message if NDEBUG is not defined.
Definition
itassert.h:163
it_assert_debug
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
Definition
itassert.h:107
mat.h
Matrix Class Definitions.
matfunc.h
Various functions on vectors and matrices - header file.
itpp
itpp namespace
Definition
itmex.h:37
itpp::operator<<
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
Definition
binary.cpp:36
specmat.h
Definitions of special vectors and matrices.
vec.h
Templated Vector Class Definitions.
Generated by
1.17.0