00001 00035 #include <itpp/comm/llr.h> 00036 00037 00038 namespace itpp { 00039 00040 LLR_calc_unit::LLR_calc_unit() 00041 { 00042 init_llr_tables(); 00043 } 00044 00045 LLR_calc_unit::LLR_calc_unit(short int d1, short int d2, short int d3) 00046 { 00047 init_llr_tables(d1,d2,d3); 00048 } 00049 00050 00051 void LLR_calc_unit::operator=(const LLR_calc_unit &x) 00052 { 00053 Dint1=x.Dint1; 00054 Dint2=x.Dint2; 00055 Dint3=x.Dint3; 00056 logexp_table=x.logexp_table; 00057 } 00058 00059 00060 ivec LLR_calc_unit::get_Dint() 00061 { 00062 ivec r(3); 00063 r(0) = Dint1; 00064 r(1) = Dint2; 00065 r(2) = Dint3; 00066 return r; 00067 } 00068 00069 void LLR_calc_unit::init_llr_tables(short int d1, short int d2, short int d3) 00070 { 00071 Dint1 = d1; // 1<<Dint1 determines how integral LLRs relate to real LLRs (to_double=(1<<Dint)*int_llr) 00072 Dint2 = d2; // number of entries in table for LLR operations 00073 Dint3 = d3; // table resolution is 2^(-(Dint1-Dint3)) 00074 // cerr << "Initializing LLR tables, Dint1=" << Dint1 << " Dint2=" << Dint2 << " Dint3=" << Dint3 00075 // << " resoltion: " << pow(2.0,((double) (Dint3-Dint1))) << endl; 00076 logexp_table = construct_logexp_table(); 00077 } 00078 00079 ivec LLR_calc_unit::construct_logexp_table() 00080 { 00081 ivec result(Dint2); 00082 for (int i=0; i<Dint2; i++) { 00083 double x= pow(2.0,((double) (Dint3-Dint1)))*((double) i); 00084 result(i) = to_qllr(log(1+exp(-x))); 00085 } 00086 it_assert1(length(result)==Dint2,"Ldpc_codec::construct_logexp_table()"); 00087 00088 return result; 00089 } 00090 00091 QLLRvec LLR_calc_unit::to_qllr(const vec &l) { 00092 int n=length(l); 00093 ivec result(n); 00094 for (int i=0; i<n; i++) { 00095 result.set(i,to_qllr(l(i))); 00096 } 00097 return result; 00098 } 00099 00100 vec LLR_calc_unit::to_double(const QLLRvec &l) { 00101 int n=length(l); 00102 vec result(n); 00103 for (int i=0; i<n; i++) { 00104 result.set(i,to_double(l(i))); 00105 } 00106 return result; 00107 } 00108 00109 QLLRmat LLR_calc_unit::to_qllr(const mat &l) { 00110 int m=l.rows(); 00111 int n=l.cols(); 00112 imat result(m,n); 00113 for (int i=0; i<m; i++) { 00114 for (int j=0; j<n; j++) { 00115 result.set(i,j,to_qllr(l(i,j))); 00116 } 00117 } 00118 return result; 00119 } 00120 00121 mat LLR_calc_unit::to_double(const QLLRmat &l) { 00122 int m=l.rows(); 00123 int n=l.cols(); 00124 mat result(m,n); 00125 for (int i=0; i<m; i++) { 00126 for (int j=0; j<n; j++) { 00127 result.set(i,j,to_double(l(i,j))); 00128 } 00129 } 00130 return result; 00131 } 00132 00133 std::ostream &operator<<(std::ostream &os, const LLR_calc_unit &lcu) 00134 { 00135 os << "---------- LLR calculation unit -----------------" << std::endl; 00136 os << "LLR_calc_unit table properties:" << std::endl; 00137 os << "The granularity in the LLR representation is " << pow(2.0,-lcu.Dint1) << std::endl; 00138 os << "The LLR scale factor is " << (1<<lcu.Dint1) << std::endl; 00139 os << "The largest LLR that can be represented is " << lcu.to_double(QLLR_MAX) << std::endl; 00140 os << "The table resolution is " << pow(2.0,((double) (lcu.Dint3-lcu.Dint1))) << std::endl; 00141 os << "The number of entries in the table is " << lcu.Dint2 << std::endl; 00142 os << "The tables truncates at the LLR value " << 00143 pow(2.0,((double) (lcu.Dint3-lcu.Dint1)))*((double) lcu.Dint2) << std::endl; 00144 os << "-------------------------------------------------" << std::endl; 00145 return os; 00146 } 00147 00148 }
Generated on Thu Apr 19 14:23:58 2007 for IT++ by Doxygen 1.4.6