Merge branch 'upstream' into dfsg-orig
[debian/gnuradio] / gr-trellis / src / lib / trellis_viterbi_s.cc
index bb3dafa61051722a5f8a344c2f17be77df04076c..94a9c0be3da5878098e57cea9f718d8967995de7 100644 (file)
@@ -6,7 +6,7 @@
  * 
  * GNU Radio is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
+ * the Free Software Foundation; either version 3, or (at your option)
  * any later version.
  * 
  * GNU Radio is distributed in the hope that it will be useful,
  * 
  * You should have received a copy of the GNU General Public License
  * along with GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
  */
 
+// WARNING: this file is machine generated.  Edits will be over written
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -52,8 +54,8 @@ trellis_viterbi_s::trellis_viterbi_s (
   d_FSM (FSM),
   d_K (K),
   d_S0 (S0),
-  d_SK (SK),
-  d_trace(FSM.S()*K)
+  d_SK (SK)//,
+  //d_trace(FSM.S()*K)
 {
     set_relative_rate (1.0 / ((double) d_FSM.O()));
     set_output_multiple (d_K);
@@ -77,13 +79,14 @@ trellis_viterbi_s::forecast (int noutput_items, gr_vector_int &ninput_items_requ
 void viterbi_algorithm(int I, int S, int O, 
              const std::vector<int> &NS,
              const std::vector<int> &OS,
-             const std::vector<int> &PS,
-             const std::vector<int> &PI,
+             const std::vector< std::vector<int> > &PS,
+             const std::vector< std::vector<int> > &PI,
              int K,
              int S0,int SK,
-             const float *in, short *out,
-             std::vector<int> &trace) 
+             const float *in, short *out)//,
+             //std::vector<int> &trace) 
 {
+  std::vector<int> trace(S*K);
   std::vector<float> alpha(S*2);
   int alphai;
   float norm,mm,minm;
@@ -105,9 +108,9 @@ void viterbi_algorithm(int I, int S, int O,
       for(int j=0;j<S;j++) { // for each next state do ACS
           minm=INF;
           minmi=0;
-          for(int i=0;i<I;i++) {
-              int i0 = j*I+i;
-              if((mm=alpha[alphai*S+PS[i0]]+in[k*O+OS[PS[i0]*I+PI[i0]]])<minm)
+          for(unsigned int i=0;i<PS[j].size();i++) {
+              //int i0 = j*I+i;
+              if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm)
                   minm=mm,minmi=i;
           }
           trace[k*S+j]=minmi;
@@ -131,9 +134,9 @@ void viterbi_algorithm(int I, int S, int O,
   }
 
   for(int k=K-1;k>=0;k--) { // traceback
-      int i0=st*I+trace[k*S+st];
-      out[k]= (short) PI[i0];
-      st=PS[i0];
+      int i0=trace[k*S+st];
+      out[k]= (short) PI[st][i0];
+      st=PS[st][i0];
   }
 
 }
@@ -158,7 +161,7 @@ trellis_viterbi_s::general_work (int noutput_items,
     const float *in = (const float *) input_items[m];
     short *out = (short *) output_items[m];
     for (int n=0;n<nblocks;n++) {
-      viterbi_algorithm(d_FSM.I(),d_FSM.S(),d_FSM.O(),d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(),d_K,d_S0,d_SK,&(in[n*d_K*d_FSM.O()]),&(out[n*d_K]),d_trace);
+      viterbi_algorithm(d_FSM.I(),d_FSM.S(),d_FSM.O(),d_FSM.NS(),d_FSM.OS(),d_FSM.PS(),d_FSM.PI(),d_K,d_S0,d_SK,&(in[n*d_K*d_FSM.O()]),&(out[n*d_K]));//,d_trace);
     }
   }