Exemplo n.º 1
0
YuleWalker<T>::YuleWalker( T *signal,
                           int seq_len,
                           int ar_ord,
                           T *a_vec,
                           double *drv_noise_var,
                           int *err_stat)
{
  int idb;
  Matrix<T> *corr_mtx;
  corr_mtx = new AutocorrMethCorrMtx<T>( signal, 
                                         seq_len, 
                                         ar_ord);

  T *correl_vec, sum;
  correl_vec = corr_mtx->GetCol(1);
  #ifdef _DEBUG
    for(idb=0; idb<=ar_ord; idb++)
    {
     DebugFile << "R[" << idb << "] = " << correl_vec[idb] << std::endl;
    }
  #endif
  *err_stat = LevinsonRecursion( correl_vec,
                                 ar_ord,
                                 a_vec,
                                 drv_noise_var);
  std::cout << "err_stat = " << (*err_stat) << std::endl;

  sum = 0.0;
  for(idb=1; idb<=ar_ord; idb++)
    {
    sum += a_vec[idb] * correl_vec[idb];
    }
  sum = correl_vec[0] - sum;
  return;
}
Exemplo n.º 2
0
YuleWalker<T>::YuleWalker( T *toep_corr_mtx,
                           int ar_ord,
                           T *a_vec,
                           double *drv_noise_var,
                           int *err_stat)
{
  *err_stat = LevinsonRecursion( toep_corr_mtx,
                                 ar_ord,
                                 a_vec,
                                 drv_noise_var);
  return;
}
Exemplo n.º 3
0
//======================================================
int YuleWalkerPsdEstim::Execute()
{
   int is;
   int error_status;
#ifdef _DEBUG
   *DebugFile << "In YuleWalkerPsdEstim::Execute\0" 
              << endl;
#endif


   if(Processing_Completed) return(_MES_AOK);
   if(PassNumber < Hold_Off) return (_MES_AOK);
   //--------------------------------
   //  Get pointers for buffers

   float *in_sig_ptr = GET_INPUT_PTR(In_Sig);

   int samps_avail = Block_Size;

   while(Samps_Needed <= samps_avail){
      //  The new input block has enough samples to
      //  finish a segment.

      //  Fill up FFT buffer by getting Samps_Needed
      //  input samples.
      for(is=Samps_Needed; is>0; is--){
         Time_Seg[Seg_Len - is] = *in_sig_ptr++;
      }
      samps_avail -= Samps_Needed;

      AutocorrMethCorrMtx *corr_mtx = 
            new AutocorrMethCorrMtx(  
                  Time_Seg, 
                  Seg_Len, 
                  Ar_Order);

      double *correl_vec = corr_mtx->GetCol(1);
      double *a_vec = new double[Ar_Order+1];
      double driving_noise_var;

      error_status = LevinsonRecursion(   
         correl_vec,
         Ar_Order,
         a_vec,
         &driving_noise_var);

      ArSpectrum *ar_spectrum = new ArSpectrum( 
               Ar_Order,
               a_vec,
               Samp_Intvl,
               driving_noise_var, //true_ar_drv_var );
               Num_Freq_Pts,
               1.0/(2*Samp_Intvl));

      ar_spectrum->DumpSpectrum( Psd_File_Name, true);

      if(Halt_When_Completed)
      {
#ifdef _DEBUG
         *DebugFile << "Execution halted by " 
                    << GetModelName() << endl;
#endif
         exit(0);
      }
   }// end of while

   //---------------------------------------------------
   //  The number of avail new samples is not sufficient
   //  to finish a segment.  Copy the avaialble samples
   //  and then wait for the next pass to get some more.

   for(is=0; is<samps_avail; is++){
      Time_Seg[Seg_Len - Samps_Needed + is] = 
                                       *in_sig_ptr++;
   }
   Samps_Needed -= samps_avail;
   return(_MES_AOK);
}