40 template class ITPP_EXPORT Modulator<double>;
41 template class ITPP_EXPORT Modulator<std::complex<double> >;
53 "QAM::set_M(): M = " <<
M <<
" is not an even power of 2");
56 double average_energy = (
M - 1) * 2.0 / 3.0;
65 for (
int i = 0; i <
L; i++) {
66 for (
int j = 0; j <
L; j++) {
70 gray_code.get_row(j)));
84 out.set_size(
k*signal.size(),
false);
86 int temp_real, temp_imag;
88 for (
int i = 0; i < signal.size(); i++) {
95 else if (temp_real > (
L - 1))
99 else if (temp_imag > (
L - 1))
101 out.replace_mid(
k*i,
bitmap.get_row(temp_imag *
L + temp_real));
128 double epsilon = delta / 10000.0;
129 std::complex<double> symb;
130 for (
int i = 0; i <
M; i++) {
131 symb = std::complex<double>(std::polar(1.0, delta * i));
132 if (std::fabs(
std::real(symb)) < epsilon) {
135 else if (std::fabs(
std::imag(symb)) < epsilon) {
157 out.set_size(
k*signal.size(),
false);
159 for (
int i = 0; i < signal.size(); i++) {
161 temp = (ang < 0) ? (
m_2pi + ang) : ang;
163 out.replace_mid(i*
k,
bitmap.get_row(est_symbol));
182 soft_bits.set_size(
k * rx_symbols.size());
183 std::complex<double> temp;
185 std::complex<double> exp_pi4 = std::complex<double>(
std::cos(
pi / 4),
187 for (
int i = 0; i < rx_symbols.size(); i++) {
188 temp = rx_symbols(i) * exp_pi4;
189 soft_bits((i << 1) + 1) =
std::real(temp) * factor;
190 soft_bits(i << 1) =
std::imag(temp) * factor;
204 double N0, vec &soft_bits,
207 soft_bits.set_size(2*rx_symbols.size(),
false);
208 std::complex<double> temp;
210 std::complex<double> exp_pi4 = std::complex<double>(
std::cos(
pi / 4),
212 for (
int i = 0; i < rx_symbols.size(); i++) {
213 temp = rx_symbols(i) *
std::conj(channel(i)) * exp_pi4;
214 soft_bits((i << 1) + 1) =
std::real(temp) * factor;
215 soft_bits(i << 1) =
std::imag(temp) * factor;
234 out.set_size(bits.size(),
false);
235 for (
int i = 0; i < bits.size(); i++) {
236 out(i) = (bits(i) == 0 ? 1.0 : -1.0);
242 cvec out(bits.size());
250 out.set_size(signal.size(),
false);
251 for (
int i = 0; i < signal.length(); i++) {
258 bvec out(signal.size());
267 double factor = 4 / N0;
268 soft_bits.set_size(rx_symbols.size(),
false);
270 for (
int i = 0; i < rx_symbols.size(); i++) {
271 soft_bits(i) = factor *
std::real(rx_symbols(i));
286 double N0, vec &soft_bits,
289 double factor = 4 / N0;
290 soft_bits.set_size(rx_symbols.size(),
false);
292 for (
int i = 0; i < rx_symbols.size(); i++) {
312 out.set_size(bits.size(),
false);
313 for (
int i = 0; i < bits.size(); i++) {
314 out(i) = (bits(i) == 0 ? 1.0 : -1.0);
320 vec out(bits.size());
328 out.set_size(signal.size(),
false);
329 for (
int i = 0; i < signal.length(); i++) {
330 out(i) = (signal(i) > 0) ?
bin(0) :
bin(1);
336 bvec out(signal.size());
345 double factor = 4 / N0;
346 soft_bits.set_size(rx_symbols.size(),
false);
348 for (
int i = 0; i < rx_symbols.size(); i++) {
349 soft_bits(i) = factor * rx_symbols(i);
363 double N0, vec &soft_bits,
366 double factor = 4 / N0;
367 soft_bits.set_size(rx_symbols.size(),
false);
369 for (
int i = 0; i < rx_symbols.size(); i++) {
370 soft_bits(i) = factor * (rx_symbols(i) * channel(i));
396 double average_energy = (
sqr(
M) - 1) / 3.0;
399 for (
int i = 0; i <
M; i++) {
414 out.set_size(
k*signal.size(),
false);
416 for (
int i = 0; i < signal.size(); i++) {
421 else if (est_symbol > (
M - 1))
423 out.replace_mid(i*
k,
bitmap.get_row(est_symbol));
429 bvec temp(signal.size());
439 double P0, P1, d0min, d1min, temp;
442 soft_bits.set_size(
k * rx_symbols.size());
445 for (
int l = 0; l < rx_symbols.size(); l++) {
446 for (
int j = 0; j <
M; j++) {
450 for (
int i = 0; i <
k; i++) {
452 for (
int j = 0; j < (M >> 1); j++) {
453 P0 += metric(
S0(i, j));
454 P1 += metric(
S1(i, j));
461 for (
int l = 0; l < rx_symbols.size(); l++) {
462 for (
int j = 0; j <
M; j++) {
465 for (
int i = 0; i <
k; i++) {
467 for (
int j = 0; j < (M >> 1); j++) {
468 temp = metric(
S0(i, j));
469 if (temp < d0min) { d0min = temp; }
470 temp = metric(
S1(i, j));
471 if (temp < d1min) { d1min = temp; }
473 soft_bits(l*k + i) = (-d0min + d1min) / N0;
489 double N0, vec &soft_bits,
493 double P0, P1, d0min, d1min, temp;
496 soft_bits.set_size(
k * rx_symbols.size());
499 for (
int l = 0; l < rx_symbols.size(); l++) {
500 for (
int j = 0; j <
M; j++) {
502 - channel(l) *
symbols(j))) / N0);
504 for (
int i = 0; i <
k; i++) {
506 for (
int j = 0; j < (M >> 1); j++) {
507 P0 += metric(
S0(i, j));
508 P1 += metric(
S1(i, j));
515 for (
int l = 0; l < rx_symbols.size(); l++) {
516 for (
int j = 0; j <
M; j++) {
519 for (
int i = 0; i <
k; i++) {
521 for (
int j = 0; j < (M >> 1); j++) {
522 temp = metric(
S0(i, j));
523 if (temp < d0min) { d0min = temp; }
524 temp = metric(
S1(i, j));
525 if (temp < d1min) { d1min = temp; }
527 soft_bits(l*k + i) = (-d0min + d1min) / N0;
555 double average_energy = (
sqr(
M) - 1) / 3.0;
558 for (
int i = 0; i <
M; i++) {
573 out.set_size(
k*signal.size(),
false);
575 for (
int i = 0; i < signal.size(); i++) {
579 else if (est_symbol > (
M - 1))
581 out.replace_mid(i*
k,
bitmap.get_row(est_symbol));
587 bvec temp(signal.size());