Show
Ignore:
Timestamp:
06/15/07 19:17:26 (6 years ago)
Author:
hvolos
Message:

fixed a bug

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • SigProc/trunk/SigProc/fec_conv.cpp

    r4184 r4187  
    228228    if (theTrellis!=NULL){ 
    229229        for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){ 
    230             delete theTrellis[i]; 
     230            delete []theTrellis[i]; 
    231231        }; 
    232232         
     
    255255void fec_conv_decoder::SetNoOfSymbols2TraceBack(unsigned int traceBackLength){ 
    256256    //std::cout<<theTrellis; 
    257     if (theTrellis!=NULL){ 
     257 
     258    if (fec_conv_decoder::noOfSymbols2TraceBack!=traceBackLength){ 
     259         fec_conv_decoder::noOfSymbols2TraceBack=traceBackLength; 
     260        if (theTrellis!=NULL){ 
     261            for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){ 
     262                delete []theTrellis[i]; 
     263            }; 
     264            delete []theTrellis; 
     265            theTrellis=NULL; 
     266        } 
     267        //std::cout<<theTrellis; 
     268        //int dummy; 
     269        //std::cin>>dummy; 
     270 
     271     
     272 
     273        theTrellis= new TrellisEntry*[theTrellisTable->numberOfTrellisStates]; 
    258274        for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){ 
    259             delete theTrellis[i]; 
     275         theTrellis[i] =new TrellisEntry[noOfSymbols2TraceBack+1]; 
    260276        }; 
    261         delete []theTrellis; 
    262         theTrellis=NULL; 
    263     } 
    264     //std::cout<<theTrellis; 
    265     //int dummy; 
    266     //std::cin>>dummy; 
    267  
    268     fec_conv_decoder::noOfSymbols2TraceBack=traceBackLength; 
    269  
    270     theTrellis= new TrellisEntry*[theTrellisTable->numberOfTrellisStates]; 
    271     for (unsigned int i = 0; i < theTrellisTable->numberOfTrellisStates; i++){ 
    272         theTrellis[i] =new TrellisEntry[noOfSymbols2TraceBack+1]; 
    273     }; 
    274  
    275     if (tracedBackSymbols!=NULL){ 
    276         delete []tracedBackSymbols; 
    277         tracedBackSymbols=NULL; 
    278     }; 
     277 
     278        if (tracedBackSymbols!=NULL){ 
     279            delete []tracedBackSymbols; 
     280            tracedBackSymbols=NULL; 
     281        }; 
    279282    tracedBackSymbols = new unsigned int [noOfSymbols2TraceBack]; 
    280283 
     284    } 
     285/* 
    281286    currentTrellisIndex=0; 
    282287    for (unsigned int i=0;i<theTrellisTable->numberOfTrellisStates;i++) 
     
    287292        } 
    288293    theTrellis[0][0].distance=0; 
    289  
     294*/ 
     295    fec_conv_decoder::Reset(); 
    290296} 
    291297 
     
    297303    signed int distance; 
    298304 
    299     inbits=0; 
     305   // inbits=0; 
    300306    for (unsigned short int i=0;i<theTrellisTable->n;i++){ 
    301307        tmp=inputData[i]; 
     
    315321    }; 
    316322 
    317      if (inbits>(unsigned int)(pow(theTrellisTable->n,2)-1)){ 
     323     if (inbits>(unsigned int)(pow(2.0,(float)theTrellisTable->n)-1)){ 
    318324        std::cout<<"ERROR:fec_conv_decoder::Symbol2Decode inbits>2^n-1\n"; 
    319         std::cout<<"inbits:"<<inbits<<" numberOfInputStates:"<<pow(theTrellisTable->n,2)-1; 
     325        std::cout<<"inbits:"<<inbits<<"   2^n-1: "<<(unsigned int)pow(2.0,(float)theTrellisTable->n)-1 
     326            <<"n="<<theTrellisTable->n<<"\n"; 
    320327        throw 0; 
    321328    };