示例#1
0
  void TurboCodeWithZP::Decoder_term(const itpp::cvec& in1,
                                     const itpp::cvec& in2,
                                     double n0, int iterations) const
  {
    // std::cout << "## zeroPadding_ = " << zeroPadding_.PadPositions() << std::endl;

    int memory = rsc1_.Constraint() - 1;
    static itpp::vec llrZeros(0);
    if (llrZeros.size() != memory){
      llrZeros.set_size(memory);
      llrZeros.zeros();
    } // if
    
    for (int ite = 0; ite < iterations; ++ite){
      itpp::vec llrToRsc1_mod = zeroPadding_.ModifyLLR(llrToRsc1_);
      
      itpp::vec llrFromRsc1;
      rsc1_.Decode(in1, llrToRsc1_mod, &llrFromRsc1, n0);
      
      itpp::vec llrFromRsc1_mod = zeroPadding_.ModifyLLR(llrFromRsc1);
            
      itpp::vec llrToRsc2 = Interleave(llrFromRsc1_mod.left(interleaver_.size()), interleaver_);
      llrToRsc2 = itpp::concat(llrToRsc2, llrZeros);

      itpp::vec llrFromRsc2;
      rsc2_.Decode(in2, llrToRsc2, &llrFromRsc2, n0);

      llrToRsc1_ = Deinterleave(llrFromRsc2.left(interleaver_.size()), interleaver_);
      llrToRsc1_ = itpp::concat(llrToRsc1_, llrZeros);
    } // for ite    
  }
示例#2
0
  void TurboCode::Decoder_term(const itpp::cvec &in1,
                               const itpp::cvec &in2,
                               double n0, int iteration) const
  {
    int memory = rsc1_.Constraint() - 1;
    static itpp::vec llrZeros(0);
    if (llrZeros.size() != memory){
      llrZeros.set_size(memory);
      llrZeros.zeros();
    } // if

    for (int ite = 0; ite < iteration; ++ite){
      itpp::vec llrFromRsc1;
      rsc1_.Decode(in1, llrToRsc1_, &llrFromRsc1, n0);

      itpp::vec llrToRsc2 = Interleave(llrFromRsc1.left(interleaver_.size()), interleaver_);
      llrToRsc2 = itpp::concat(llrToRsc2, llrZeros);

      itpp::vec llrFromRsc2;
      rsc2_.Decode(in2, llrToRsc2, &llrFromRsc2, n0);

      llrToRsc1_ = Deinterleave(llrFromRsc2.left(interleaver_.size()), interleaver_);
      llrToRsc1_ = itpp::concat(llrToRsc1_, llrZeros);
    } // for ite

  }
示例#3
0
文件: siso_eq.cpp 项目: nvmd/itpp
void SISO::equalizer_maxlogMAP(itpp::vec &extrinsic_data, const itpp::vec &rec_sig, const itpp::vec &apriori_data)
/*
  extrinsic_data - extrinsic information for channel input symbols
  rec_sig - received symbols
  apriori_data - a priori information for channel input symbols
 */
{
    //get parameters
    int N = rec_sig.length();//length of the received frame
    //other parameters
    register int n,k,m;
    int pstates[2];
    int nstates[2];
    int inputs[2];
    double C[2];//log(gamma)
    double sum;
    double sumbis;
    double buffer;

    //initialize trellis
    gen_chtrellis();
    //initialize log(alpha) and log(beta)
    double* A = new double[chtrellis.stateNb*(N+1)];
    double* B = new double[chtrellis.stateNb*(N+1)];
    A[0] = 0;
    for (n=1; n<chtrellis.stateNb; n++)
        A[n] = -INFINITY;
    B[N*chtrellis.stateNb] = 0;
    sum = (tail?-INFINITY:0);
    for (n=1; n<chtrellis.stateNb; n++)
        B[n+N*chtrellis.stateNb] = sum;//if tail==false the final state is not known

#pragma omp parallel sections private(n,sum,m,k,C)
    {
        //forward recursion
        for (n=1; n<=N; n++)
        {
            sum = -INFINITY;//normalization factor
            for (m=0; m<chtrellis.stateNb; m++) //final state
            {
                for (k=0; k<2; k++)
                {
                    pstates[k] = chtrellis.prevState[m+chtrellis.stateNb*k];//determine previous states
                    inputs[k] = chtrellis.input[m+chtrellis.stateNb*k];//determine input
                    C[k] = (inputs[k])*apriori_data[n-1]-itpp::sqr(rec_sig[n-1]-chtrellis.output[pstates[k]+chtrellis.stateNb*inputs[k]])/(2*sigma2);//compute log of gamma
                }
                A[m+n*chtrellis.stateNb] = std::max(A[pstates[0]+(n-1)*chtrellis.stateNb]+C[0], A[pstates[1]+(n-1)*chtrellis.stateNb]+C[1]);
                sum = std::max(sum, A[m+n*chtrellis.stateNb]);
            }
            for (m=0; m<chtrellis.stateNb; m++)
                A[m+n*chtrellis.stateNb] -= sum;
        }

        //backward recursion
#pragma omp section
        for (n=N-1; n>=0; n--)
        {
            sum = -INFINITY;//normalisation factor
            for (m=0; m<chtrellis.stateNb; m++) //initial state
            {
                for (k=0; k<2; k++)
                {
                    nstates[k] = chtrellis.nextState[m+k*chtrellis.stateNb];//determine next states
                    C[k] = (k)*apriori_data[n]-itpp::sqr(rec_sig[n]-chtrellis.output[m+k*chtrellis.stateNb])/(2*sigma2);//compute log of gamma
                }
                B[m+n*chtrellis.stateNb] = std::max(B[nstates[0]+(n+1)*chtrellis.stateNb]+C[0], B[nstates[1]+(n+1)*chtrellis.stateNb]+C[1]);
                sum = std::max(sum, B[m+n*chtrellis.stateNb]);
            }
            for (m=0; m<chtrellis.stateNb; m++)
                B[m+n*chtrellis.stateNb] -= sum;
        }
    }

    //compute extrinsic_data
    extrinsic_data.set_size(N);
    for (n=1; n<=N; n++)
    {
        sum = -INFINITY;
        sumbis = -INFINITY;
        for (m=0; m<chtrellis.stateNb; m++) //initial state
        {
            for (k=0; k<2; k++) //input index
            {
                nstates[k] = chtrellis.nextState[m+k*chtrellis.stateNb];//determine next states
                C[k] = (k)*apriori_data[n-1]-itpp::sqr(rec_sig[n-1]-chtrellis.output[m+k*chtrellis.stateNb])/(2*sigma2);//compute log of gamma
                buffer = A[m+(n-1)*chtrellis.stateNb]+C[k]+B[nstates[k]+n*chtrellis.stateNb];
                if (k)
                    sum = std::max(sum, buffer);//1
                else
                    sumbis = std::max(sumbis, buffer);//0
            }
        }
        extrinsic_data[n-1] = (sum-sumbis)-apriori_data[n-1];
    }

    //free memory
    delete[] chtrellis.output;
    delete[] chtrellis.nextState;
    delete[] chtrellis.prevState;
    delete[] chtrellis.input;
    delete[] A;
    delete[] B;
}