i got the code from this site that is supposed to put the bits from an array into a vector, but it does not work and i don't know what i am doing wrong:
1 2 3 4 5 6 7 8 9 10 11 12
decode_rs(); // recd[] will be error corrected and in polynomial form
// put recd[]s into decoded_lcw[]
for(i=nn-kk; i < nn; i++)
{
decoded_lcw[i - (nn-kk) + index*(nn-kk)] = recd[i];
}
}
//put values of decoded_lcw[] into decoded_lcw_vec()
decoded_lcw_vec( decoded_lcw, decoded_lcw + sizeof(decoded_lcw)/sizeof(decoded_lcw[0]) ) ;
delete [] decoded_lcw;
}
the error is:
error: no match for call to '(bit_vec {aka std::vector<int>}) (int*&, int*)'
the decoded_lcw_vec vector is typed like this:
typedef std::vector<int> bit_vec;
i wanted to use vector<bool> being that i am dealing with bits here but i thought maybe the conversion from int to bool was the problem but obviously i get the same error when the vector is typed int. any help will be much appreciated, thanks in advance.
what is recd and decoded_lcw. Further more: why delete [] decoded_lcw;?
if decoded_lcw is a pointer to a vector you need either derefernce or -> to access the function: (*decoded_lcw)[i - (nn-kk) + index*(nn-kk)] = recd[i];
#define mm 6 /* RS code over GF(2**6) */
#define nn 24 /* nn=2**mm -1 length of codeword */
#define tt 6 /* number of errors that can be corrected */
#define kk 12 /* kk = nn-2*tt */
int pp [mm+1] = { 1, 1, 0, 0, 0, 0, 1 } ; /* specify irreducible polynomial coeffts */
int alpha_to [nn+1], index_of [nn+1], gg [nn-kk+1] ;
int recd [nn], data [kk], bb [nn-kk] ;
// 1st parameter is 144 bit array from the hamming decode
// 2nd parameter is 72 bit array filled by this decoder
void
ldu1::decode_reed_solomon(uint16_t* rs_codeword)
{
generate_gf( ) ;
gen_poly( ) ;
int decoded_lcw[72] = {0} ;
int i;
int parity[72] = {0}; // 72-bit array for parity bits
int payload[72] = {0}; // 72-bit array for data bits
for (i=72; i<144; i++) parity[i-72] = rs_codeword[i] ; // split 72 parity bits from rs_codewords
for (i=0; i<72; i++) payload[i] = rs_codeword[i] ; // split 72 data bits from rs_codewords
for(int index = 0; index < 6; index++)// form and decode 6 24-bit codewords
{
int i; // putting the bits in rec[nn]
for (i=0; i<nn-kk; i++) recd[i] = bb[ i + (index*(nn-kk)) ] ; // the 12 parity hex-bits first
for (i=0; i<kk; i++) recd[i+nn-kk] = data[ i + (index*(nn-kk)) ] ; // the 12 data hex-bits second
// put 24-bit codeword into index form;
for (i=0; i<nn; i++)
recd[i] = index_of[recd[i]] ;
decode_rs(); // recd[] will be error corrected and in polynomial form
// put six 12-bit recd[]s into decoded_lcw[]
for(i=nn-kk; i < nn; i++)
{
decoded_lcw[i - (nn-kk) + index*(nn-kk)] = recd[i];
}
}
printf("decoded lcw:\n");
for(i=0;i<72;i++)
printf("%d",decoded_lcw[i]);
printf("\n");
decoded_lcw_vec(decoded_lcw, decoded_lcw + sizeof decoded_lcw / sizeof decoded_lcw[0]) ;
for(int i = 0 ; i < 72; i++ )
cout<< "\n Vector = " << decoded_lcw_vec[i] ;
}
but the error remains:
error: no match for call to '(bit_vec {aka std::vector<int>}) (int [72], int*)'
typedef std::vector<int> bit_vec;
typedefconst std::vector<int> const_bit_vec;
//Return a reference to the decoded link control word
const_bit_vec& decoded_lcw() const;
//bit vector to store the decoded link control word
bit_vec decoded_lcw_vec;
i am trying to fill the vector (on line 48 above) with the contents of the array decoded_lcw like this:
Do you have operator() overloaded for the vector? Or are you trying to call constructor(copy). Basically what I think you want is
bit_vec decoded_lcw_vec(decoded_lcw, decoded_lcw + sizeof decoded_lcw / sizeof decoded_lcw[0]) ; to call the copy constructor instead of trying to call the default constructor then operator().
Ps you could simply put 72 instead of the sizeof since it doesn't look dynamic at all. http://ideone.com/IFIAkH