7 #include <itpp/itbase.h>
8 #include <itpp/itcomm.h>
20 bool converge =
false;
25 for (
int i =0; i< row;i++){
56 itpp::bvec bits_out = llr <0;
63 itpp::GF2mat
read_one_matrix(
char * filename_prefix,
char * type,
char * filename_suffix){
66 sprintf( filename,
"%s%s%s",filename_prefix, type, filename_suffix);
72 int check_matrices(itpp::GF2mat * G, itpp::GF2mat * H, itpp::GF2mat *U, itpp::GF2mat * W, itpp::mat * K){
75 std::cout<<
"debug read matrices by checking some relation of the output matrices"<<std::endl;
83 std::cout<<
"if G*H is zero? ->"<<( ( *G * (*H).transpose()).is_zero() ?
"yes":
"no" )<<std::endl;
85 if ( G->cols() == H->cols() && G->cols()==U->cols() && G->cols() == K->cols()-1 && G->rows() == W->rows() ){
86 std::cout<<
"dimension matches"<<std::endl;
88 std::cout<<
"dimension does NOT match"<<std::endl;
93 for (
int i =0; i< H->cols();i++){
95 for (
int j=0;j<H->rows();j++)
96 if ( H->get(j,i) ) wt++;
98 std::cout<<
"find column wt < 1 in H. column index "<<i<<
" wt = "<<wt<<std::endl;
101 for (
int i =0; i< H->rows();i++){
103 for (
int j=0;j<H->cols();j++)
104 if ( H->get(i,j) ) wt++;
106 std::cout<<
"find row wt < 2 in H. column index "<<i<<
" wt = "<<wt<<std::endl;
108 std::cout<<H -> rows()<<
" row rank "<<H->row_rank()<<std::endl;
112 std::cout<<
"min weight of G: "<<d<<std::endl;
113 std::cout<<
"finish checking matrices"<<std::endl;
119 int rows=G->rows(), cols=G->cols();
120 itpp::ivec perm(rows);
123 for (
int i =0; i<rows;i++){
124 if (rows_to_remove(rows-i-1)){
125 perm(rows-1-t)= rows-i-1;
132 for (
int i = 0; i< rows;i++){
133 if (rows_to_remove(rows-i-1)){
138 perm(rows-i-t-1+t1)=rows-i-1;
143 G->permute_rows(perm,
false);
144 G->set_size(rows-t,cols,
true);
149 itpp::GF2mat H = G->transpose();
152 itpp::GF2mat H1 = H.transpose();
159 int size = cols_to_remove.size();
161 for (
int i = size-1; i>-1;i--){
162 if ( cols_to_remove(i) ){
163 for (
int j=i;j<size-t-1;j++){
169 int rows=G->rows(),cols=G->cols();
170 G->set_size(rows,cols-t,
true);
176 for (
int i =0; i< H->rows();i++){
178 for (
int j=0;j<H->cols();j++)
179 if ( H->get(i,j) ) wt++;
189 int reduce_matrices( itpp::GF2mat * G, itpp::GF2mat * H, itpp::GF2mat *U, itpp::GF2mat * W, itpp::mat * K){
194 itpp::bvec columns_to_remove = itpp::zeros_b(H->cols());
196 itpp::bvec rows_to_remove = itpp::zeros_b(H->rows());
197 for (
int i =0; i< H->rows();i++){
199 for (
int j=0;j<H->cols();j++)
200 if ( H->get(i,j) ) wt++;
203 rows_to_remove.set(i,1);
205 for (
int j=0;j<H->cols();j++)
206 if ( H->get(i,j) ) columns_to_remove.set(j,1);
230 int read_matrices_for_partial_sum(
char * filename_prefix,
char * filename_suffix, itpp::GF2mat * G, itpp::GF2mat * H, itpp::GF2mat *U, itpp::GF2mat * W, itpp::mat * K){
238 sprintf( filename,
"%s%s%s",filename_prefix,
"K", filename_suffix);