34 void STC::Hassibi_block_code(
void)
51 if (code_name==
"V-BLAST_MxN")
53 symb_block = channel_uses*em_antennas;
54 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameter is predefined:" << std::endl;
55 std::cout <<
"symb_block = channel_uses*em_antennas = " << symb_block << std::endl;
56 A.set_size(symb_block*channel_uses, em_antennas);
58 itpp::mat temp(channel_uses, em_antennas);
61 for (tau=0; tau<channel_uses; tau++)
63 for (m=0; m<em_antennas; m++)
66 A.set_submatrix((em_antennas*(tau-1)+m-1), 0,
to_cmat(temp));
72 else if (code_name==
"imp_V-BLAST_MxN")
74 if (channel_uses!=em_antennas)
76 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" channel_uses and em_antennas must be equal. Choosing channel_uses=em_antennas" << std::endl;
77 channel_uses = em_antennas;
79 symb_block = channel_uses*em_antennas;
80 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameter is predefined:" << std::endl;
81 std::cout <<
"symb_block = " << symb_block << std::endl;
82 std::complex<double> j(0,1);
85 P(0,em_antennas-1) = 1;
86 A.set_size(symb_block*channel_uses, em_antennas);
89 for (k=0; k<channel_uses; k++)
90 for (l=0; l<em_antennas; l++)
91 A.set_submatrix((em_antennas*k+l)*channel_uses, 0, diag_pow(D, k)*
itpp::to_cmat(mat_pow(P, l))/
std::sqrt(
double(em_antennas)));
94 else if (code_name==
"Alamouti_2xN")
99 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
100 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
110 else if (code_name==
"Switched_Alamouti_4xN")
115 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
116 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
152 else if (code_name==
"Double_Alamouti_4xN")
157 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
158 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
176 else if (code_name==
"Jafarkhani_4xN")
181 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
182 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
216 else if (code_name==
"Golden_2x2")
221 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
222 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
223 std::complex<double> theta((1+
std::sqrt(5.0))/2,0);
224 std::complex<double> theta_b((1-
std::sqrt(5.0))/2,0);
225 std::complex<double> j(0,1);
226 std::complex<double> one(1,0);
227 std::complex<double> alpha = one+j*(one-theta);
228 std::complex<double> alpha_b = one+j*(one-theta_b);
229 std::complex<double>
gamma = j;
244 A(6,1) = gamma*alpha_b*theta_b/
std::sqrt(5.0);
249 else if (code_name==
"Damen_2x2")
254 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
255 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
259 else if (const_size==16)
261 else if (const_size>=256)
266 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" and const. size " << const_size <<
", lambda has the value " << lambda << std::endl;
268 std::complex<double> j(0,1);
269 std::complex<double> phi =
std::exp(j*lambda);
270 std::complex<double> theta =
std::exp(j*(lambda/2));
290 else if (code_name==
"34ortho_3xN")
295 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
296 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
324 else if (code_name==
"36LD_3xN")
329 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
330 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
394 B(4,1) = double(-1)/double(2);
396 B(5,0) = double(-1)/double(2);
398 B(5,2) = double(-1)/double(2);
400 B(6,1) = double(-1)/double(2);
402 B(7,0) = double(1)/double(2);
404 B(7,2) = double(-1)/double(2);
406 B(8,1) = double(1)/double(2);
408 B(9,0) = double(1)/double(2);
410 B(9,2) = double(1)/double(2);
412 B(10,1) = double(1)/double(2);
414 B(11,0) = double(-1)/double(2);
416 B(11,2) = double(1)/double(2);
430 else if (code_name==
"37LD_3xN")
435 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
436 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
512 else if (code_name==
"39LD_3xN")
517 std::cout <<
"STC::LDcode: Warning! For " << code_name <<
" the following parameters are predefined:" << std::endl;
518 std::cout <<
"em_antennas = " << em_antennas <<
", channel_uses = " << channel_uses <<
", symb_block = " << symb_block << std::endl;
739 std::cout <<
"STC::LDcode: unknown code name. Available codes are: V-BLAST_MxN, imp_V-BLAST_MxN, Alamouti_2xN, \
740 Switched_Alamouti_4xN, Double_Alamouti_4xN, Jafarkhani_4xN, Golden_2x2, Damen_2x2, 34ortho_3xN, 36LD_3xN, 37LD_3xN, 39LD_3xN" << std::endl;
743 itpp::cmat STC::Hassibi_encode(
const itpp::cvec &symb)
746 int nb_subblocks = symb.length()/symb_block;
747 int tx_duration = channel_uses*nb_subblocks;
748 itpp::cmat S(tx_duration,em_antennas);
749 itpp::cmat temp(channel_uses,em_antennas);
750 std::complex<double> j(0,1);
752 for (ns=0; ns<nb_subblocks; ns++)
755 for (k=0; k<symb_block; k++)
756 temp += (A(k*channel_uses,(k+1)*channel_uses-1,0,em_antennas-1)*
static_cast< std::complex<double>
>(symb(k+ns*symb_block).
real())\
757 +j*B(k*channel_uses,(k+1)*channel_uses-1,0,em_antennas-1)*
static_cast< std::complex<double>
>(symb(k+ns*symb_block).
imag()));
758 S.set_submatrix(ns*channel_uses, 0, temp);
763 inline itpp::cmat STC::diag_pow(
const itpp::cmat &in_mat,
const double &in_exp)
767 int dim = in_mat.rows();
768 itpp::cmat out_mat(dim,dim);
769 for (n=0; n<dim; n++)
770 out_mat(n,n) =
std::pow(in_mat(n,n), in_exp);
774 inline itpp::mat STC::mat_pow(
const itpp::mat &in_mat,
const int &in_exp)
779 itpp::mat out = in_mat;
782 for (n=1; n<abs_in_exp; n++)