diff options
Diffstat (limited to 'gr-trellis/src')
80 files changed, 1401 insertions, 560 deletions
diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am index 935fe9fbf..769d4a338 100644 --- a/gr-trellis/src/lib/Makefile.am +++ b/gr-trellis/src/lib/Makefile.am @@ -65,9 +65,11 @@ _trellis_la_SOURCES = \ trellis.cc \ fsm.cc \ quicksort_index.cc \ + base.cc \ interleaver.cc \ trellis_calc_metric.cc \ trellis_permutation.cc \ + trellis_siso_f.cc \ $(GENERATED_CC) # magic flags @@ -87,10 +89,13 @@ trellis.cc trellis.py: $(ALL_IFILES) grinclude_HEADERS = \ fsm.h \ quicksort_index.h \ + base.h \ interleaver.h \ trellis_metric_type.h \ trellis_calc_metric.h \ trellis_permutation.h \ + trellis_siso_type.h \ + trellis_siso_f.h \ $(GENERATED_H) diff --git a/gr-trellis/src/lib/base.cc b/gr-trellis/src/lib/base.cc new file mode 100644 index 000000000..35ba2ea1d --- /dev/null +++ b/gr-trellis/src/lib/base.cc @@ -0,0 +1,92 @@ +/* -*- c++ -*- */
+/*
+ * Copyright 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * 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)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+#include <cstdio>
+#include <stdexcept>
+#include <cmath>
+#include "base.h"
+
+
+bool dec2base(unsigned int num, int base, std::vector<int> &s)
+{
+ int l = s.size();
+ unsigned int n=num;
+ for(int i=0;i<l;i++) {
+ s[l-i-1] = n % base; //MSB first
+ n /= base;
+ }
+ if(n!=0) {
+ printf("Number %d requires more than %d digits.",num,l);
+ return false;
+ }
+ else
+ return true;
+}
+
+
+unsigned int base2dec(const std::vector<int> &s, int base)
+{
+ int l = s.size();
+ unsigned int num=0;
+ for(int i=0;i<l;i++)
+ num=num*base+s[i];
+ return num;
+}
+
+
+bool dec2bases(unsigned int num, const std::vector<int> &bases, std::vector<int> &s)
+{
+ int l = s.size();
+ unsigned int n=num;
+ for(int i=0;i<l;i++) {
+ s[l-i-1] = n % bases[l-i-1];
+ n /= bases[l-i-1];
+ }
+ if(n!=0) {
+ printf("Number %d requires more than %d digits.",num,l);
+ return false;
+ }
+ else
+ return true;
+}
+
+
+
+unsigned int bases2dec(const std::vector<int> &s, const std::vector<int> &bases)
+{
+ int l = s.size();
+ unsigned int num=0;
+ for(int i=0;i<l;i++)
+ num = num * bases[i] + s[i];
+ return num;
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gr-trellis/src/lib/base.h b/gr-trellis/src/lib/base.h new file mode 100644 index 000000000..b0fe3e91d --- /dev/null +++ b/gr-trellis/src/lib/base.h @@ -0,0 +1,38 @@ +/* -*- c++ -*- */
+/*
+ * Copyright 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * 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)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+#ifndef INCLUDED_TRELLIS_BASE_H
+#define INCLUDED_TRELLIS_BASE_H
+
+#include <vector>
+
+/*!
+ * \brief change base
+ */
+
+
+bool dec2base(unsigned int num, int base, std::vector<int> &s);
+bool dec2bases(unsigned int num, const std::vector<int> &bases, std::vector<int> &s);
+unsigned int base2dec(const std::vector<int> &s, int base);
+unsigned int bases2dec(const std::vector<int> &s, const std::vector<int> &bases);
+
+#endif
diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index 05d1589fe..f34308834 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -23,8 +23,10 @@ #include <cstdio>
#include <stdexcept>
#include <cmath>
+#include "base.h"
#include "fsm.h"
+
fsm::fsm()
{
d_I=0;
@@ -34,6 +36,8 @@ fsm::fsm() d_OS.resize(0);
d_PS.resize(0);
d_PI.resize(0);
+ d_TMi.resize(0);
+ d_TMl.resize(0);
}
fsm::fsm(const fsm &FSM)
@@ -45,28 +49,20 @@ fsm::fsm(const fsm &FSM) d_OS=FSM.OS();
d_PS=FSM.PS();
d_PI=FSM.PI();
+ d_TMi=FSM.TMi();
+ d_TMl=FSM.TMl();
}
-fsm::fsm(const int I, const int S, const int O, const std::vector<int> &NS, const std::vector<int> &OS)
+fsm::fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS)
{
d_I=I;
d_S=S;
d_O=O;
d_NS=NS;
d_OS=OS;
- d_PS.resize(d_I*d_S);
- d_PI.resize(d_I*d_S);
-
- // generate the PS, PI tables for later use
- for(int i=0;i<d_S;i++) {
- int j=0;
- for(int ii=0;ii<d_S;ii++) for(int jj=0;jj<d_I;jj++) {
- if(d_NS[ii*d_I+jj]!=i) continue;
- d_PS[i*d_I+j]=ii;
- d_PI[i*d_I+j]=jj;
- j++;
- }
- }
+
+ generate_PS_PI();
+ generate_TM();
}
//######################################################################
@@ -84,14 +80,12 @@ fsm::fsm(const char *name) FILE *fsmfile;
if((fsmfile=fopen(name,"r"))==NULL)
- throw std::runtime_error ("file open error in fsm()");
+ throw std::runtime_error ("fsm::fsm(const char *name): file open error\n");
//printf("file open error in fsm()\n");
fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O);
d_NS.resize(d_I*d_S);
d_OS.resize(d_I*d_S);
- d_PS.resize(d_I*d_S);
- d_PI.resize(d_I*d_S);
for(int i=0;i<d_S;i++) {
for(int j=0;j<d_I;j++) fscanf(fsmfile,"%d",&(d_NS[i*d_I+j]));
@@ -99,25 +93,128 @@ fsm::fsm(const char *name) for(int i=0;i<d_S;i++) {
for(int j=0;j<d_I;j++) fscanf(fsmfile,"%d",&(d_OS[i*d_I+j]));
}
+
+ generate_PS_PI();
+ generate_TM();
+}
+
+
+
+
+//######################################################################
+//# Automatically generate the FSM from the generator matrix
+//# of a (n,k) binary convolutional code
+//######################################################################
+fsm::fsm(int k, int n, const std::vector<int> &G)
+{
+
+ // calculate maximum memory requirements for each input stream
+ std::vector<int> max_mem_x(k,-1);
+ int max_mem = -1;
+ for(int i=0;i<k;i++) {
+ for(int j=0;j<n;j++) {
+ int mem = -1;
+ if(G[i*n+j]!=0)
+ mem=(int)(log(G[i*n+j])/log(2.0));
+ if(mem>max_mem_x[i])
+ max_mem_x[i]=mem;
+ if(mem>max_mem)
+ max_mem=mem;
+ }
+ }
- // generate the PS, PI tables for later use
- for(int i=0;i<d_S;i++) {
- int j=0;
- for(int ii=0;ii<d_S;ii++) for(int jj=0;jj<d_I;jj++) {
- if(d_NS[ii*d_I+jj]!=i) continue;
- d_PS[i*d_I+j]=ii;
- d_PI[i*d_I+j]=jj;
- j++;
+//printf("max_mem_x\n");
+//for(int j=0;j<max_mem_x.size();j++) printf("%d ",max_mem_x[j]); printf("\n");
+
+ // calculate total memory requirements to set S
+ int sum_max_mem = 0;
+ for(int i=0;i<k;i++)
+ sum_max_mem += max_mem_x[i];
+
+//printf("sum_max_mem = %d\n",sum_max_mem);
+
+ d_I=1<<k;
+ d_S=1<<sum_max_mem;
+ d_O=1<<n;
+
+ // binary representation of the G matrix
+ std::vector<std::vector<int> > Gb(k*n);
+ for(int j=0;j<k*n;j++) {
+ Gb[j].resize(max_mem+1);
+ dec2base(G[j],2,Gb[j]);
+//printf("Gb\n");
+//for(int m=0;m<Gb[j].size();m++) printf("%d ",Gb[j][m]); printf("\n");
+ }
+
+ // alphabet size of each shift register
+ std::vector<int> bases_x(k);
+ for(int j=0;j<k ;j++)
+ bases_x[j] = 1 << max_mem_x[j];
+//printf("bases_x\n");
+//for(int j=0;j<max_mem_x.size();j++) printf("%d ",max_mem_x[j]); printf("\n");
+
+ d_NS.resize(d_I*d_S);
+ d_OS.resize(d_I*d_S);
+
+ std::vector<int> sx(k);
+ std::vector<int> nsx(k);
+ std::vector<int> tx(k);
+ std::vector<std::vector<int> > tb(k);
+ for(int j=0;j<k;j++)
+ tb[j].resize(max_mem+1);
+ std::vector<int> inb(k);
+ std::vector<int> outb(n);
+
+
+ for(int s=0;s<d_S;s++) {
+ dec2bases(s,bases_x,sx); // split s into k values, each representing on of the k shift registers
+//printf("state = %d \nstates = ",s);
+//for(int j=0;j<sx.size();j++) printf("%d ",sx[j]); printf("\n");
+ for(int i=0;i<d_I;i++) {
+ dec2base(i,2,inb); // input in binary
+//printf("input = %d \ninputs = ",i);
+//for(int j=0;j<inb.size();j++) printf("%d ",inb[j]); printf("\n");
+
+ // evaluate next state
+ for(int j=0;j<k;j++)
+ nsx[j] = (inb[j]*bases_x[j]+sx[j])/2; // next state (for each shift register) MSB first
+ d_NS[s*d_I+i]=bases2dec(nsx,bases_x); // collect all values into the new state
+
+ // evaluate transitions
+ for(int j=0;j<k;j++)
+ tx[j] = inb[j]*bases_x[j]+sx[j]; // transition (for each shift register)MSB first
+ for(int j=0;j<k;j++) {
+ dec2base(tx[j],2,tb[j]); // transition in binary
+//printf("transition = %d \ntransitions = ",tx[j]);
+//for(int m=0;m<tb[j].size();m++) printf("%d ",tb[j][m]); printf("\n");
+ }
+
+ // evaluate outputs
+ for(int nn=0;nn<n;nn++) {
+ outb[nn] = 0;
+ for(int j=0;j<k;j++) {
+ for(int m=0;m<max_mem+1;m++)
+ outb[nn] = (outb[nn] + Gb[j*n+nn][m]*tb[j][m]) % 2; // careful: polynomial 1+D ir represented as 110, not as 011
+//printf("output %d equals %d\n",nn,outb[nn]);
+ }
+ }
+ d_OS[s*d_I+i] = base2dec(outb,2);
}
}
+
+ generate_PS_PI();
+ generate_TM();
}
+
+
+
//######################################################################
//# Automatically generate an FSM specification describing the
//# ISI for a channel
//# of length ch_length and a modulation of size mod_size
//######################################################################
-fsm::fsm(const int mod_size, const int ch_length)
+fsm::fsm(int mod_size, int ch_length)
{
d_I=mod_size;
d_S=(int) (pow(1.0*d_I,1.0*ch_length-1)+0.5);
@@ -125,8 +222,6 @@ fsm::fsm(const int mod_size, const int ch_length) d_NS.resize(d_I*d_S);
d_OS.resize(d_I*d_S);
- d_PS.resize(d_I*d_S);
- d_PI.resize(d_I*d_S);
for(int s=0;s<d_S;s++) {
for(int i=0;i<d_I;i++) {
@@ -135,8 +230,20 @@ fsm::fsm(const int mod_size, const int ch_length) d_OS[s*d_I+i] = t;
}
}
-
- // generate the PS, PI tables for later use
+
+ generate_PS_PI();
+ generate_TM();
+}
+
+
+//######################################################################
+//# generate the PS and PI tables for later use
+//######################################################################
+void fsm::generate_PS_PI()
+{
+ d_PS.resize(d_I*d_S);
+ d_PI.resize(d_I*d_S);
+
for(int i=0;i<d_S;i++) {
int j=0;
for(int ii=0;ii<d_S;ii++) for(int jj=0;jj<d_I;jj++) {
@@ -147,3 +254,70 @@ fsm::fsm(const int mod_size, const int ch_length) }
}
}
+
+
+//######################################################################
+//# generate the termination matrices TMl and TMi for later use
+//######################################################################
+void fsm::generate_TM()
+{
+ d_TMi.resize(d_S*d_S);
+ d_TMl.resize(d_S*d_S);
+
+ for(int i=0;i<d_S*d_S;i++) {
+ d_TMi[i] = -1; // no meaning
+ d_TMl[i] = d_S; //infinity: you need at most S-1 steps
+ if (i/d_S == i%d_S)
+ d_TMl[i] = 0;
+ }
+
+ for(int s=0;s<d_S;s++) {
+ bool done = false;
+ int attempts = 0;
+ while (done == false && attempts < d_S-1) {
+ done = find_es(s);
+ attempts ++;
+ }
+ if (done == false)
+ //throw std::runtime_error ("fsm::generate_TM(): FSM appears to be disconnected\n");
+ printf("fsm::generate_TM(): FSM appears to be disconnected\n");
+ }
+}
+
+
+// find a path from any state to the ending state "es"
+bool fsm::find_es(int es)
+{
+ bool done = true;
+ for(int s=0;s<d_S;s++) {
+ if(d_TMl[s*d_S+es] < d_S)
+ continue;
+ int minl=d_S;
+ int mini=-1;
+ for(int i=0;i<d_I;i++) {
+ if( 1 + d_TMl[d_NS[s*d_I+i]*d_S+es] < minl) {
+ minl = 1 + d_TMl[d_NS[s*d_I+i]*d_S+es];
+ mini = i;
+ }
+ }
+ if (mini != -1) {
+ d_TMl[s*d_S+es]=minl;
+ d_TMi[s*d_S+es]=mini;
+ }
+ else
+ done = false;
+ }
+ return done;
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h index b5a8e0d5b..01703e35f 100644 --- a/gr-trellis/src/lib/fsm.h +++ b/gr-trellis/src/lib/fsm.h @@ -37,12 +37,18 @@ private: std::vector<int> d_OS;
std::vector<int> d_PS;
std::vector<int> d_PI;
+ std::vector<int> d_TMi;
+ std::vector<int> d_TMl;
+ void generate_PS_PI ();
+ void generate_TM ();
+ bool find_es(int es);
public:
fsm();
fsm(const fsm &FSM);
- fsm(const int I, const int S, const int O, const std::vector<int> &NS, const std::vector<int> &OS);
+ fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS);
fsm(const char *name);
- fsm(const int mod_size, const int ch_length);
+ fsm(int k, int n, const std::vector<int> &G);
+ fsm(int mod_size, int ch_length);
int I () const { return d_I; }
int S () const { return d_S; }
int O () const { return d_O; }
@@ -50,6 +56,8 @@ public: const std::vector<int> & OS () const { return d_OS; }
const std::vector<int> & PS () const { return d_PS; }
const std::vector<int> & PI () const { return d_PI; }
+ const std::vector<int> & TMi () const { return d_TMi; }
+ const std::vector<int> & TMl () const { return d_TMl; }
};
#endif
diff --git a/gr-trellis/src/lib/fsm.i b/gr-trellis/src/lib/fsm.i index eda8aeefd..e5b1af0ca 100644 --- a/gr-trellis/src/lib/fsm.i +++ b/gr-trellis/src/lib/fsm.i @@ -29,12 +29,17 @@ private: std::vector<int> d_OS; std::vector<int> d_PS; std::vector<int> d_PI; + std::vector<int> d_TMi; + std::vector<int> d_TMl; + void generate_PS_PI (); + void generate_TM (); public: fsm(); fsm(const fsm &FSM); - fsm(const int I, const int S, const int O, const std::vector<int> &NS, const std::vector<int> &OS); + fsm(int I, int S, int O, const std::vector<int> &NS, const std::vector<int> &OS); fsm(const char *name); - fsm(const int mod_size, const int ch_length); + fsm(int k, int n, const std::vector<int> &G); + fsm(int mod_size, int ch_length); int I () const { return d_I; } int S () const { return d_S; } int O () const { return d_O; } @@ -42,8 +47,7 @@ public: const std::vector<int> & OS () const { return d_OS; } const std::vector<int> & PS () const { return d_PS; } const std::vector<int> & PI () const { return d_PI; } + const std::vector<int> & TMi () const { return d_TMi; } + const std::vector<int> & TMl () const { return d_TMl; } }; - - - diff --git a/gr-trellis/src/lib/interleaver.cc b/gr-trellis/src/lib/interleaver.cc index 042dc04ba..174d31c0b 100644 --- a/gr-trellis/src/lib/interleaver.cc +++ b/gr-trellis/src/lib/interleaver.cc @@ -42,7 +42,7 @@ interleaver::interleaver(const interleaver &INTERLEAVER) d_DEINTER=INTERLEAVER.DEINTER();
}
-interleaver::interleaver(const int K, const std::vector<int> &INTER)
+interleaver::interleaver(int K, const std::vector<int> &INTER)
{
d_K=K;
d_INTER=INTER;
@@ -85,7 +85,7 @@ interleaver::interleaver(const char *name) //######################################################################
//# Generate a random interleaver
//######################################################################
-interleaver::interleaver(const int K, unsigned int seed)
+interleaver::interleaver(int K, unsigned int seed)
{
d_K=K;
d_INTER.resize(d_K);
diff --git a/gr-trellis/src/lib/interleaver.h b/gr-trellis/src/lib/interleaver.h index 13c316be2..14ed80faf 100644 --- a/gr-trellis/src/lib/interleaver.h +++ b/gr-trellis/src/lib/interleaver.h @@ -36,9 +36,9 @@ private: public:
interleaver();
interleaver(const interleaver & INTERLEAVER);
- interleaver(const int K, const std::vector<int> & INTER);
+ interleaver(int K, const std::vector<int> & INTER);
interleaver(const char *name);
- interleaver(const int K, unsigned int seed);
+ interleaver(int K, unsigned int seed);
int K () const { return d_K; }
const std::vector<int> & INTER () const { return d_INTER; }
const std::vector<int> & DEINTER () const { return d_DEINTER; }
diff --git a/gr-trellis/src/lib/interleaver.i b/gr-trellis/src/lib/interleaver.i index 6baec3bdc..625bd8620 100644 --- a/gr-trellis/src/lib/interleaver.i +++ b/gr-trellis/src/lib/interleaver.i @@ -28,9 +28,9 @@ private: public:
interleaver();
interleaver(const interleaver & INTERLEAVER);
- interleaver(const int K, const std::vector<int> & INTER);
+ interleaver(int K, const std::vector<int> & INTER);
interleaver(const char *name);
- interleaver(const int K, unsigned int seed);
+ interleaver(int K, unsigned int seed);
int K () const { return d_K; }
const std::vector<int> & INTER () const { return d_INTER; }
const std::vector<int> & DEINTER () const { return d_DEINTER; }
diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i index bd3144119..983576e83 100644 --- a/gr-trellis/src/lib/trellis.i +++ b/gr-trellis/src/lib/trellis.i @@ -10,6 +10,7 @@ #include "fsm.h" #include "interleaver.h" #include "trellis_permutation.h" +#include "trellis_siso_f.h" #include <stdexcept> %} @@ -18,7 +19,10 @@ %include "fsm.i" %include "interleaver.i" %include "trellis_permutation.i" +%include "trellis_siso_f.i" + %include "trellis_metric_type.h" +%include "trellis_siso_type.h" %include "trellis_generated.i" diff --git a/gr-trellis/src/lib/trellis_calc_metric.cc b/gr-trellis/src/lib/trellis_calc_metric.cc index ae25a67ba..5faa4b7c7 100644 --- a/gr-trellis/src/lib/trellis_calc_metric.cc +++ b/gr-trellis/src/lib/trellis_calc_metric.cc @@ -24,8 +24,7 @@ #include <stdexcept> #include "trellis_calc_metric.h" -// soft decisions (Euclidean distance squared) -void calc_metric_s(const int O, const int D, const std::vector<short> &TABLE, const short *in, float *metric, trellis_metric_type_t type) +void calc_metric_s(int O, int D, const std::vector<short> &TABLE, const short *in, float *metric, trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; @@ -33,24 +32,24 @@ void calc_metric_s(const int O, const int D, const std::vector<short> &TABLE, co switch (type){ case TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } + metric[o]=0.0; + for (int m=0;m<D;m++) { + float s=in[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } } break; case TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } + metric[o]=0.0; + for (int m=0;m<D;m++) { + float s=in[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } + if(metric[o]<minm) { + minm=metric[o]; + minmi=o; + } } for(int o=0;o<O;o++) { metric[o] = (o==minmi?0.0:1.0); @@ -66,8 +65,7 @@ void calc_metric_s(const int O, const int D, const std::vector<short> &TABLE, co -// soft decisions (Euclidean distance squared) -void calc_metric_i(const int O, const int D, const std::vector<int> &TABLE, const int *in, float *metric, trellis_metric_type_t type) +void calc_metric_i(int O, int D, const std::vector<int> &TABLE, const int *in, float *metric, trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; @@ -75,24 +73,24 @@ void calc_metric_i(const int O, const int D, const std::vector<int> &TABLE, cons switch (type){ case TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } + metric[o]=0.0; + for (int m=0;m<D;m++) { + float s=in[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } } break; case TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } + metric[o]=0.0; + for (int m=0;m<D;m++) { + float s=in[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } + if(metric[o]<minm) { + minm=metric[o]; + minmi=o; + } } for(int o=0;o<O;o++) { metric[o] = (o==minmi?0.0:1.0); @@ -108,12 +106,7 @@ void calc_metric_i(const int O, const int D, const std::vector<int> &TABLE, cons - - - - -// soft decisions (Euclidean distance squared) -void calc_metric_f(const int O, const int D, const std::vector<float> &TABLE, const float *in, float *metric, trellis_metric_type_t type) +void calc_metric_f(int O, int D, const std::vector<float> &TABLE, const float *in, float *metric, trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; @@ -121,24 +114,24 @@ void calc_metric_f(const int O, const int D, const std::vector<float> &TABLE, co switch (type){ case TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } + metric[o]=0.0; + for (int m=0;m<D;m++) { + float s=in[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } } break; case TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { - metric[o]=0.0; - for (int m=0;m<D;m++) { - float s=in[m]-TABLE[o*D+m]; - metric[o]+=s*s; - } - if(metric[o]<minm) { - minm=metric[o]; - minmi=o; - } + metric[o]=0.0; + for (int m=0;m<D;m++) { + float s=in[m]-TABLE[o*D+m]; + metric[o]+=s*s; + } + if(metric[o]<minm) { + minm=metric[o]; + minmi=o; + } } for(int o=0;o<O;o++) { metric[o] = (o==minmi?0.0:1.0); @@ -153,8 +146,7 @@ void calc_metric_f(const int O, const int D, const std::vector<float> &TABLE, co } -// soft decisions (Euclidean distance squared) -void calc_metric_c(const int O, const int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, float *metric, trellis_metric_type_t type) +void calc_metric_c(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, float *metric, trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; @@ -169,7 +161,20 @@ void calc_metric_c(const int O, const int D, const std::vector<gr_complex> &TABL } } case TRELLIS_HARD_SYMBOL: - throw std::runtime_error ("Invalid metric type (not yet implemented)."); + for(int o=0;o<O;o++) { + metric[o]=0.0; + for (int m=0;m<D;m++) { + gr_complex s=in[m]-TABLE[o*D+m]; + metric[o]+=s.real()*s.real()+s.imag()*s.imag(); + } + if(metric[o]<minm) { + minm=metric[o]; + minmi=o; + } + } + for(int o=0;o<O;o++) { + metric[o] = (o==minmi?0.0:1.0); + } break; case TRELLIS_HARD_BIT: throw std::runtime_error ("Invalid metric type (not yet implemented)."); diff --git a/gr-trellis/src/lib/trellis_calc_metric.h b/gr-trellis/src/lib/trellis_calc_metric.h index 1e1805322..0f66d82d8 100644 --- a/gr-trellis/src/lib/trellis_calc_metric.h +++ b/gr-trellis/src/lib/trellis_calc_metric.h @@ -27,12 +27,12 @@ #include <gr_complex.h> #include <trellis_metric_type.h> -void calc_metric_s(const int O, const int D, const std::vector<short> &TABLE, const short *in, float *metric, trellis_metric_type_t type); +void calc_metric_s(int O, int D, const std::vector<short> &TABLE, const short *in, float *metric, trellis_metric_type_t type); -void calc_metric_i(const int O, const int D, const std::vector<int> &TABLE, const int *in, float *metric, trellis_metric_type_t type); +void calc_metric_i(int O, int D, const std::vector<int> &TABLE, const int *in, float *metric, trellis_metric_type_t type); -void calc_metric_f(const int O, const int D, const std::vector<float> &TABLE, const float *in, float *metric, trellis_metric_type_t type); +void calc_metric_f(int O, int D, const std::vector<float> &TABLE, const float *in, float *metric, trellis_metric_type_t type); -void calc_metric_c(const int O, const int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, float *metric, trellis_metric_type_t type); +void calc_metric_c(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, float *metric, trellis_metric_type_t type); #endif diff --git a/gr-trellis/src/lib/trellis_encoder_XX.cc.t b/gr-trellis/src/lib/trellis_encoder_XX.cc.t index 75ae0750a..810951e64 100644 --- a/gr-trellis/src/lib/trellis_encoder_XX.cc.t +++ b/gr-trellis/src/lib/trellis_encoder_XX.cc.t @@ -29,12 +29,12 @@ #include <iostream> @SPTR_NAME@ -trellis_make_@BASE_NAME@ (const fsm &FSM, const int ST) +trellis_make_@BASE_NAME@ (const fsm &FSM, int ST) { return @SPTR_NAME@ (new @NAME@ (FSM,ST)); } -@NAME@::@NAME@ (const fsm &FSM, const int ST) +@NAME@::@NAME@ (const fsm &FSM, int ST) : gr_sync_block ("@BASE_NAME@", gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), gr_make_io_signature (1, -1, sizeof (@O_TYPE@))), @@ -50,26 +50,24 @@ int gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int d_ST_tmp; + int ST_tmp; assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[m]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; - d_ST_tmp = d_ST; + for (int m=0;m<nstreams;m++) { + const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[m]; + @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; + ST_tmp = d_ST; -// per stream processing - - for (int i = 0; i < noutput_items; i++){ - out[i] = (@O_TYPE@) d_FSM.OS()[d_ST_tmp*d_FSM.I()+in[i]]; // direction of time? - d_ST_tmp = (int) d_FSM.NS()[d_ST_tmp*d_FSM.I()+in[i]]; + // per stream processing + for (int i = 0; i < noutput_items; i++){ + out[i] = (@O_TYPE@) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing } - -// end per stream processing -} - d_ST = d_ST_tmp; + d_ST = ST_tmp; return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_encoder_XX.h.t b/gr-trellis/src/lib/trellis_encoder_XX.h.t index bfca5ee40..26c220489 100644 --- a/gr-trellis/src/lib/trellis_encoder_XX.h.t +++ b/gr-trellis/src/lib/trellis_encoder_XX.h.t @@ -31,7 +31,7 @@ class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, const int ST); +@SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. @@ -42,10 +42,10 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; class @NAME@ : public gr_sync_block { private: - friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, const int ST); + friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST); fsm d_FSM; int d_ST; - @NAME@ (const fsm &FSM, const int ST); + @NAME@ (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_encoder_XX.i.t b/gr-trellis/src/lib/trellis_encoder_XX.i.t index ea015a84f..e5627be79 100644 --- a/gr-trellis/src/lib/trellis_encoder_XX.i.t +++ b/gr-trellis/src/lib/trellis_encoder_XX.i.t @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); -@SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, const int ST); +@SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST); class @NAME@ : public gr_sync_block { private: - @NAME@ (const fsm &FSM, const int ST); + @NAME@ (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } int ST () const { return d_ST; } diff --git a/gr-trellis/src/lib/trellis_encoder_bb.cc b/gr-trellis/src/lib/trellis_encoder_bb.cc index aecba87a4..cad4490ad 100644 --- a/gr-trellis/src/lib/trellis_encoder_bb.cc +++ b/gr-trellis/src/lib/trellis_encoder_bb.cc @@ -29,12 +29,12 @@ #include <iostream> trellis_encoder_bb_sptr -trellis_make_encoder_bb (const fsm &FSM, const int ST) +trellis_make_encoder_bb (const fsm &FSM, int ST) { return trellis_encoder_bb_sptr (new trellis_encoder_bb (FSM,ST)); } -trellis_encoder_bb::trellis_encoder_bb (const fsm &FSM, const int ST) +trellis_encoder_bb::trellis_encoder_bb (const fsm &FSM, int ST) : gr_sync_block ("encoder_bb", gr_make_io_signature (1, -1, sizeof (unsigned char)), gr_make_io_signature (1, -1, sizeof (unsigned char))), @@ -50,26 +50,24 @@ trellis_encoder_bb::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int d_ST_tmp; + int ST_tmp; assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const unsigned char *in = (const unsigned char *) input_items[m]; - unsigned char *out = (unsigned char *) output_items[m]; - d_ST_tmp = d_ST; + for (int m=0;m<nstreams;m++) { + const unsigned char *in = (const unsigned char *) input_items[m]; + unsigned char *out = (unsigned char *) output_items[m]; + ST_tmp = d_ST; -// per stream processing - - for (int i = 0; i < noutput_items; i++){ - out[i] = (unsigned char) d_FSM.OS()[d_ST_tmp*d_FSM.I()+in[i]]; // direction of time? - d_ST_tmp = (int) d_FSM.NS()[d_ST_tmp*d_FSM.I()+in[i]]; + // per stream processing + for (int i = 0; i < noutput_items; i++){ + out[i] = (unsigned char) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing } - -// end per stream processing -} - d_ST = d_ST_tmp; + d_ST = ST_tmp; return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_encoder_bb.h b/gr-trellis/src/lib/trellis_encoder_bb.h index a3817f2e7..f2d7a3ace 100644 --- a/gr-trellis/src/lib/trellis_encoder_bb.h +++ b/gr-trellis/src/lib/trellis_encoder_bb.h @@ -31,7 +31,7 @@ class trellis_encoder_bb; typedef boost::shared_ptr<trellis_encoder_bb> trellis_encoder_bb_sptr; -trellis_encoder_bb_sptr trellis_make_encoder_bb (const fsm &FSM, const int ST); +trellis_encoder_bb_sptr trellis_make_encoder_bb (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. @@ -42,10 +42,10 @@ trellis_encoder_bb_sptr trellis_make_encoder_bb (const fsm &FSM, const int ST); class trellis_encoder_bb : public gr_sync_block { private: - friend trellis_encoder_bb_sptr trellis_make_encoder_bb (const fsm &FSM, const int ST); + friend trellis_encoder_bb_sptr trellis_make_encoder_bb (const fsm &FSM, int ST); fsm d_FSM; int d_ST; - trellis_encoder_bb (const fsm &FSM, const int ST); + trellis_encoder_bb (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_encoder_bb.i b/gr-trellis/src/lib/trellis_encoder_bb.i index 07f5606e6..4610d967e 100644 --- a/gr-trellis/src/lib/trellis_encoder_bb.i +++ b/gr-trellis/src/lib/trellis_encoder_bb.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,encoder_bb); -trellis_encoder_bb_sptr trellis_make_encoder_bb (const fsm &FSM, const int ST); +trellis_encoder_bb_sptr trellis_make_encoder_bb (const fsm &FSM, int ST); class trellis_encoder_bb : public gr_sync_block { private: - trellis_encoder_bb (const fsm &FSM, const int ST); + trellis_encoder_bb (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } int ST () const { return d_ST; } diff --git a/gr-trellis/src/lib/trellis_encoder_bi.cc b/gr-trellis/src/lib/trellis_encoder_bi.cc index 968527b8f..d0848be63 100644 --- a/gr-trellis/src/lib/trellis_encoder_bi.cc +++ b/gr-trellis/src/lib/trellis_encoder_bi.cc @@ -29,12 +29,12 @@ #include <iostream> trellis_encoder_bi_sptr -trellis_make_encoder_bi (const fsm &FSM, const int ST) +trellis_make_encoder_bi (const fsm &FSM, int ST) { return trellis_encoder_bi_sptr (new trellis_encoder_bi (FSM,ST)); } -trellis_encoder_bi::trellis_encoder_bi (const fsm &FSM, const int ST) +trellis_encoder_bi::trellis_encoder_bi (const fsm &FSM, int ST) : gr_sync_block ("encoder_bi", gr_make_io_signature (1, -1, sizeof (unsigned char)), gr_make_io_signature (1, -1, sizeof (int))), @@ -50,26 +50,24 @@ trellis_encoder_bi::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int d_ST_tmp; + int ST_tmp; assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const unsigned char *in = (const unsigned char *) input_items[m]; - int *out = (int *) output_items[m]; - d_ST_tmp = d_ST; + for (int m=0;m<nstreams;m++) { + const unsigned char *in = (const unsigned char *) input_items[m]; + int *out = (int *) output_items[m]; + ST_tmp = d_ST; -// per stream processing - - for (int i = 0; i < noutput_items; i++){ - out[i] = (int) d_FSM.OS()[d_ST_tmp*d_FSM.I()+in[i]]; // direction of time? - d_ST_tmp = (int) d_FSM.NS()[d_ST_tmp*d_FSM.I()+in[i]]; + // per stream processing + for (int i = 0; i < noutput_items; i++){ + out[i] = (int) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing } - -// end per stream processing -} - d_ST = d_ST_tmp; + d_ST = ST_tmp; return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_encoder_bi.h b/gr-trellis/src/lib/trellis_encoder_bi.h index 5212f6416..d86f38b68 100644 --- a/gr-trellis/src/lib/trellis_encoder_bi.h +++ b/gr-trellis/src/lib/trellis_encoder_bi.h @@ -31,7 +31,7 @@ class trellis_encoder_bi; typedef boost::shared_ptr<trellis_encoder_bi> trellis_encoder_bi_sptr; -trellis_encoder_bi_sptr trellis_make_encoder_bi (const fsm &FSM, const int ST); +trellis_encoder_bi_sptr trellis_make_encoder_bi (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. @@ -42,10 +42,10 @@ trellis_encoder_bi_sptr trellis_make_encoder_bi (const fsm &FSM, const int ST); class trellis_encoder_bi : public gr_sync_block { private: - friend trellis_encoder_bi_sptr trellis_make_encoder_bi (const fsm &FSM, const int ST); + friend trellis_encoder_bi_sptr trellis_make_encoder_bi (const fsm &FSM, int ST); fsm d_FSM; int d_ST; - trellis_encoder_bi (const fsm &FSM, const int ST); + trellis_encoder_bi (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_encoder_bi.i b/gr-trellis/src/lib/trellis_encoder_bi.i index 4fd389e94..06531196e 100644 --- a/gr-trellis/src/lib/trellis_encoder_bi.i +++ b/gr-trellis/src/lib/trellis_encoder_bi.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,encoder_bi); -trellis_encoder_bi_sptr trellis_make_encoder_bi (const fsm &FSM, const int ST); +trellis_encoder_bi_sptr trellis_make_encoder_bi (const fsm &FSM, int ST); class trellis_encoder_bi : public gr_sync_block { private: - trellis_encoder_bi (const fsm &FSM, const int ST); + trellis_encoder_bi (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } int ST () const { return d_ST; } diff --git a/gr-trellis/src/lib/trellis_encoder_bs.cc b/gr-trellis/src/lib/trellis_encoder_bs.cc index 9546e3d9d..34876044b 100644 --- a/gr-trellis/src/lib/trellis_encoder_bs.cc +++ b/gr-trellis/src/lib/trellis_encoder_bs.cc @@ -29,12 +29,12 @@ #include <iostream> trellis_encoder_bs_sptr -trellis_make_encoder_bs (const fsm &FSM, const int ST) +trellis_make_encoder_bs (const fsm &FSM, int ST) { return trellis_encoder_bs_sptr (new trellis_encoder_bs (FSM,ST)); } -trellis_encoder_bs::trellis_encoder_bs (const fsm &FSM, const int ST) +trellis_encoder_bs::trellis_encoder_bs (const fsm &FSM, int ST) : gr_sync_block ("encoder_bs", gr_make_io_signature (1, -1, sizeof (unsigned char)), gr_make_io_signature (1, -1, sizeof (short))), @@ -50,26 +50,24 @@ trellis_encoder_bs::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int d_ST_tmp; + int ST_tmp; assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const unsigned char *in = (const unsigned char *) input_items[m]; - short *out = (short *) output_items[m]; - d_ST_tmp = d_ST; + for (int m=0;m<nstreams;m++) { + const unsigned char *in = (const unsigned char *) input_items[m]; + short *out = (short *) output_items[m]; + ST_tmp = d_ST; -// per stream processing - - for (int i = 0; i < noutput_items; i++){ - out[i] = (short) d_FSM.OS()[d_ST_tmp*d_FSM.I()+in[i]]; // direction of time? - d_ST_tmp = (int) d_FSM.NS()[d_ST_tmp*d_FSM.I()+in[i]]; + // per stream processing + for (int i = 0; i < noutput_items; i++){ + out[i] = (short) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing } - -// end per stream processing -} - d_ST = d_ST_tmp; + d_ST = ST_tmp; return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_encoder_bs.h b/gr-trellis/src/lib/trellis_encoder_bs.h index 2ddf5505c..d0a99ffe7 100644 --- a/gr-trellis/src/lib/trellis_encoder_bs.h +++ b/gr-trellis/src/lib/trellis_encoder_bs.h @@ -31,7 +31,7 @@ class trellis_encoder_bs; typedef boost::shared_ptr<trellis_encoder_bs> trellis_encoder_bs_sptr; -trellis_encoder_bs_sptr trellis_make_encoder_bs (const fsm &FSM, const int ST); +trellis_encoder_bs_sptr trellis_make_encoder_bs (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. @@ -42,10 +42,10 @@ trellis_encoder_bs_sptr trellis_make_encoder_bs (const fsm &FSM, const int ST); class trellis_encoder_bs : public gr_sync_block { private: - friend trellis_encoder_bs_sptr trellis_make_encoder_bs (const fsm &FSM, const int ST); + friend trellis_encoder_bs_sptr trellis_make_encoder_bs (const fsm &FSM, int ST); fsm d_FSM; int d_ST; - trellis_encoder_bs (const fsm &FSM, const int ST); + trellis_encoder_bs (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_encoder_bs.i b/gr-trellis/src/lib/trellis_encoder_bs.i index 51fc1d481..5179aaa84 100644 --- a/gr-trellis/src/lib/trellis_encoder_bs.i +++ b/gr-trellis/src/lib/trellis_encoder_bs.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,encoder_bs); -trellis_encoder_bs_sptr trellis_make_encoder_bs (const fsm &FSM, const int ST); +trellis_encoder_bs_sptr trellis_make_encoder_bs (const fsm &FSM, int ST); class trellis_encoder_bs : public gr_sync_block { private: - trellis_encoder_bs (const fsm &FSM, const int ST); + trellis_encoder_bs (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } int ST () const { return d_ST; } diff --git a/gr-trellis/src/lib/trellis_encoder_ii.cc b/gr-trellis/src/lib/trellis_encoder_ii.cc index 3469a235d..11e3a4fdb 100644 --- a/gr-trellis/src/lib/trellis_encoder_ii.cc +++ b/gr-trellis/src/lib/trellis_encoder_ii.cc @@ -29,12 +29,12 @@ #include <iostream> trellis_encoder_ii_sptr -trellis_make_encoder_ii (const fsm &FSM, const int ST) +trellis_make_encoder_ii (const fsm &FSM, int ST) { return trellis_encoder_ii_sptr (new trellis_encoder_ii (FSM,ST)); } -trellis_encoder_ii::trellis_encoder_ii (const fsm &FSM, const int ST) +trellis_encoder_ii::trellis_encoder_ii (const fsm &FSM, int ST) : gr_sync_block ("encoder_ii", gr_make_io_signature (1, -1, sizeof (int)), gr_make_io_signature (1, -1, sizeof (int))), @@ -50,26 +50,24 @@ trellis_encoder_ii::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int d_ST_tmp; + int ST_tmp; assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const int *in = (const int *) input_items[m]; - int *out = (int *) output_items[m]; - d_ST_tmp = d_ST; + for (int m=0;m<nstreams;m++) { + const int *in = (const int *) input_items[m]; + int *out = (int *) output_items[m]; + ST_tmp = d_ST; -// per stream processing - - for (int i = 0; i < noutput_items; i++){ - out[i] = (int) d_FSM.OS()[d_ST_tmp*d_FSM.I()+in[i]]; // direction of time? - d_ST_tmp = (int) d_FSM.NS()[d_ST_tmp*d_FSM.I()+in[i]]; + // per stream processing + for (int i = 0; i < noutput_items; i++){ + out[i] = (int) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing } - -// end per stream processing -} - d_ST = d_ST_tmp; + d_ST = ST_tmp; return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_encoder_ii.h b/gr-trellis/src/lib/trellis_encoder_ii.h index b0a9cee02..091e3ede3 100644 --- a/gr-trellis/src/lib/trellis_encoder_ii.h +++ b/gr-trellis/src/lib/trellis_encoder_ii.h @@ -31,7 +31,7 @@ class trellis_encoder_ii; typedef boost::shared_ptr<trellis_encoder_ii> trellis_encoder_ii_sptr; -trellis_encoder_ii_sptr trellis_make_encoder_ii (const fsm &FSM, const int ST); +trellis_encoder_ii_sptr trellis_make_encoder_ii (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. @@ -42,10 +42,10 @@ trellis_encoder_ii_sptr trellis_make_encoder_ii (const fsm &FSM, const int ST); class trellis_encoder_ii : public gr_sync_block { private: - friend trellis_encoder_ii_sptr trellis_make_encoder_ii (const fsm &FSM, const int ST); + friend trellis_encoder_ii_sptr trellis_make_encoder_ii (const fsm &FSM, int ST); fsm d_FSM; int d_ST; - trellis_encoder_ii (const fsm &FSM, const int ST); + trellis_encoder_ii (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_encoder_ii.i b/gr-trellis/src/lib/trellis_encoder_ii.i index c05cbb36c..aaf36d781 100644 --- a/gr-trellis/src/lib/trellis_encoder_ii.i +++ b/gr-trellis/src/lib/trellis_encoder_ii.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,encoder_ii); -trellis_encoder_ii_sptr trellis_make_encoder_ii (const fsm &FSM, const int ST); +trellis_encoder_ii_sptr trellis_make_encoder_ii (const fsm &FSM, int ST); class trellis_encoder_ii : public gr_sync_block { private: - trellis_encoder_ii (const fsm &FSM, const int ST); + trellis_encoder_ii (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } int ST () const { return d_ST; } diff --git a/gr-trellis/src/lib/trellis_encoder_si.cc b/gr-trellis/src/lib/trellis_encoder_si.cc index 581ffe286..c2b6463da 100644 --- a/gr-trellis/src/lib/trellis_encoder_si.cc +++ b/gr-trellis/src/lib/trellis_encoder_si.cc @@ -29,12 +29,12 @@ #include <iostream> trellis_encoder_si_sptr -trellis_make_encoder_si (const fsm &FSM, const int ST) +trellis_make_encoder_si (const fsm &FSM, int ST) { return trellis_encoder_si_sptr (new trellis_encoder_si (FSM,ST)); } -trellis_encoder_si::trellis_encoder_si (const fsm &FSM, const int ST) +trellis_encoder_si::trellis_encoder_si (const fsm &FSM, int ST) : gr_sync_block ("encoder_si", gr_make_io_signature (1, -1, sizeof (short)), gr_make_io_signature (1, -1, sizeof (int))), @@ -50,26 +50,24 @@ trellis_encoder_si::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int d_ST_tmp; + int ST_tmp; assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const short *in = (const short *) input_items[m]; - int *out = (int *) output_items[m]; - d_ST_tmp = d_ST; + for (int m=0;m<nstreams;m++) { + const short *in = (const short *) input_items[m]; + int *out = (int *) output_items[m]; + ST_tmp = d_ST; -// per stream processing - - for (int i = 0; i < noutput_items; i++){ - out[i] = (int) d_FSM.OS()[d_ST_tmp*d_FSM.I()+in[i]]; // direction of time? - d_ST_tmp = (int) d_FSM.NS()[d_ST_tmp*d_FSM.I()+in[i]]; + // per stream processing + for (int i = 0; i < noutput_items; i++){ + out[i] = (int) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing } - -// end per stream processing -} - d_ST = d_ST_tmp; + d_ST = ST_tmp; return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_encoder_si.h b/gr-trellis/src/lib/trellis_encoder_si.h index d42db7a99..969763dc1 100644 --- a/gr-trellis/src/lib/trellis_encoder_si.h +++ b/gr-trellis/src/lib/trellis_encoder_si.h @@ -31,7 +31,7 @@ class trellis_encoder_si; typedef boost::shared_ptr<trellis_encoder_si> trellis_encoder_si_sptr; -trellis_encoder_si_sptr trellis_make_encoder_si (const fsm &FSM, const int ST); +trellis_encoder_si_sptr trellis_make_encoder_si (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. @@ -42,10 +42,10 @@ trellis_encoder_si_sptr trellis_make_encoder_si (const fsm &FSM, const int ST); class trellis_encoder_si : public gr_sync_block { private: - friend trellis_encoder_si_sptr trellis_make_encoder_si (const fsm &FSM, const int ST); + friend trellis_encoder_si_sptr trellis_make_encoder_si (const fsm &FSM, int ST); fsm d_FSM; int d_ST; - trellis_encoder_si (const fsm &FSM, const int ST); + trellis_encoder_si (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_encoder_si.i b/gr-trellis/src/lib/trellis_encoder_si.i index e1166a6f2..0d8a16bdc 100644 --- a/gr-trellis/src/lib/trellis_encoder_si.i +++ b/gr-trellis/src/lib/trellis_encoder_si.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,encoder_si); -trellis_encoder_si_sptr trellis_make_encoder_si (const fsm &FSM, const int ST); +trellis_encoder_si_sptr trellis_make_encoder_si (const fsm &FSM, int ST); class trellis_encoder_si : public gr_sync_block { private: - trellis_encoder_si (const fsm &FSM, const int ST); + trellis_encoder_si (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } int ST () const { return d_ST; } diff --git a/gr-trellis/src/lib/trellis_encoder_ss.cc b/gr-trellis/src/lib/trellis_encoder_ss.cc index 96604a34b..3d0016b62 100644 --- a/gr-trellis/src/lib/trellis_encoder_ss.cc +++ b/gr-trellis/src/lib/trellis_encoder_ss.cc @@ -29,12 +29,12 @@ #include <iostream> trellis_encoder_ss_sptr -trellis_make_encoder_ss (const fsm &FSM, const int ST) +trellis_make_encoder_ss (const fsm &FSM, int ST) { return trellis_encoder_ss_sptr (new trellis_encoder_ss (FSM,ST)); } -trellis_encoder_ss::trellis_encoder_ss (const fsm &FSM, const int ST) +trellis_encoder_ss::trellis_encoder_ss (const fsm &FSM, int ST) : gr_sync_block ("encoder_ss", gr_make_io_signature (1, -1, sizeof (short)), gr_make_io_signature (1, -1, sizeof (short))), @@ -50,26 +50,24 @@ trellis_encoder_ss::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int d_ST_tmp; + int ST_tmp; assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const short *in = (const short *) input_items[m]; - short *out = (short *) output_items[m]; - d_ST_tmp = d_ST; + for (int m=0;m<nstreams;m++) { + const short *in = (const short *) input_items[m]; + short *out = (short *) output_items[m]; + ST_tmp = d_ST; -// per stream processing - - for (int i = 0; i < noutput_items; i++){ - out[i] = (short) d_FSM.OS()[d_ST_tmp*d_FSM.I()+in[i]]; // direction of time? - d_ST_tmp = (int) d_FSM.NS()[d_ST_tmp*d_FSM.I()+in[i]]; + // per stream processing + for (int i = 0; i < noutput_items; i++){ + out[i] = (short) d_FSM.OS()[ST_tmp*d_FSM.I()+in[i]]; // direction of time? + ST_tmp = (int) d_FSM.NS()[ST_tmp*d_FSM.I()+in[i]]; + } + // end per stream processing } - -// end per stream processing -} - d_ST = d_ST_tmp; + d_ST = ST_tmp; return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_encoder_ss.h b/gr-trellis/src/lib/trellis_encoder_ss.h index 96e1a19bd..2254306eb 100644 --- a/gr-trellis/src/lib/trellis_encoder_ss.h +++ b/gr-trellis/src/lib/trellis_encoder_ss.h @@ -31,7 +31,7 @@ class trellis_encoder_ss; typedef boost::shared_ptr<trellis_encoder_ss> trellis_encoder_ss_sptr; -trellis_encoder_ss_sptr trellis_make_encoder_ss (const fsm &FSM, const int ST); +trellis_encoder_ss_sptr trellis_make_encoder_ss (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. @@ -42,10 +42,10 @@ trellis_encoder_ss_sptr trellis_make_encoder_ss (const fsm &FSM, const int ST); class trellis_encoder_ss : public gr_sync_block { private: - friend trellis_encoder_ss_sptr trellis_make_encoder_ss (const fsm &FSM, const int ST); + friend trellis_encoder_ss_sptr trellis_make_encoder_ss (const fsm &FSM, int ST); fsm d_FSM; int d_ST; - trellis_encoder_ss (const fsm &FSM, const int ST); + trellis_encoder_ss (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_encoder_ss.i b/gr-trellis/src/lib/trellis_encoder_ss.i index ac194306f..8cb1d8ef6 100644 --- a/gr-trellis/src/lib/trellis_encoder_ss.i +++ b/gr-trellis/src/lib/trellis_encoder_ss.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,encoder_ss); -trellis_encoder_ss_sptr trellis_make_encoder_ss (const fsm &FSM, const int ST); +trellis_encoder_ss_sptr trellis_make_encoder_ss (const fsm &FSM, int ST); class trellis_encoder_ss : public gr_sync_block { private: - trellis_encoder_ss (const fsm &FSM, const int ST); + trellis_encoder_ss (const fsm &FSM, int ST); public: fsm FSM () const { return d_FSM; } int ST () const { return d_ST; } diff --git a/gr-trellis/src/lib/trellis_metrics_X.cc.t b/gr-trellis/src/lib/trellis_metrics_X.cc.t index 2dd1adb12..7ace0298a 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.cc.t +++ b/gr-trellis/src/lib/trellis_metrics_X.cc.t @@ -32,14 +32,14 @@ @SPTR_NAME@ -trellis_make_@BASE_NAME@ (const int O, const int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) +trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) { return @SPTR_NAME@ (new @NAME@ (O,D,TABLE,TYPE)); } -@NAME@::@NAME@ (const int O, const int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) +@NAME@::@NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) : gr_block ("@BASE_NAME@", gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), gr_make_io_signature (1, -1, sizeof (float))), diff --git a/gr-trellis/src/lib/trellis_metrics_X.h.t b/gr-trellis/src/lib/trellis_metrics_X.h.t index 626791dd4..ef01793ab 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.h.t +++ b/gr-trellis/src/lib/trellis_metrics_X.h.t @@ -31,7 +31,7 @@ class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ trellis_make_@BASE_NAME@ (const int O, const int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); +@SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -45,8 +45,8 @@ class @NAME@ : public gr_block trellis_metric_type_t d_TYPE; std::vector<@I_TYPE@> d_TABLE; - friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (const int O, const int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); - @NAME@ (const int O, const int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); + friend @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); + @NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_X.i.t b/gr-trellis/src/lib/trellis_metrics_X.i.t index 2fc3ba8ff..1687d8fb4 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.i.t +++ b/gr-trellis/src/lib/trellis_metrics_X.i.t @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); -@SPTR_NAME@ trellis_make_@BASE_NAME@ (const int O, const int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); +@SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); class @NAME@ : public gr_block { private: - @NAME@ (const int O, const int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); + @NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_c.cc b/gr-trellis/src/lib/trellis_metrics_c.cc index ea1808e83..d80f2e7d7 100644 --- a/gr-trellis/src/lib/trellis_metrics_c.cc +++ b/gr-trellis/src/lib/trellis_metrics_c.cc @@ -32,14 +32,14 @@ trellis_metrics_c_sptr -trellis_make_metrics_c (const int O, const int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE) +trellis_make_metrics_c (int O, int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE) { return trellis_metrics_c_sptr (new trellis_metrics_c (O,D,TABLE,TYPE)); } -trellis_metrics_c::trellis_metrics_c (const int O, const int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE) +trellis_metrics_c::trellis_metrics_c (int O, int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE) : gr_block ("metrics_c", gr_make_io_signature (1, -1, sizeof (gr_complex)), gr_make_io_signature (1, -1, sizeof (float))), diff --git a/gr-trellis/src/lib/trellis_metrics_c.h b/gr-trellis/src/lib/trellis_metrics_c.h index 5de578401..57a549cb7 100644 --- a/gr-trellis/src/lib/trellis_metrics_c.h +++ b/gr-trellis/src/lib/trellis_metrics_c.h @@ -31,7 +31,7 @@ class trellis_metrics_c; typedef boost::shared_ptr<trellis_metrics_c> trellis_metrics_c_sptr; -trellis_metrics_c_sptr trellis_make_metrics_c (const int O, const int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_c_sptr trellis_make_metrics_c (int O, int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -45,8 +45,8 @@ class trellis_metrics_c : public gr_block trellis_metric_type_t d_TYPE; std::vector<gr_complex> d_TABLE; - friend trellis_metrics_c_sptr trellis_make_metrics_c (const int O, const int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); - trellis_metrics_c (const int O, const int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); + friend trellis_metrics_c_sptr trellis_make_metrics_c (int O, int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_c (int O, int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_c.i b/gr-trellis/src/lib/trellis_metrics_c.i index 6813cb946..cb5a116d0 100644 --- a/gr-trellis/src/lib/trellis_metrics_c.i +++ b/gr-trellis/src/lib/trellis_metrics_c.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,metrics_c); -trellis_metrics_c_sptr trellis_make_metrics_c (const int O, const int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_c_sptr trellis_make_metrics_c (int O, int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); class trellis_metrics_c : public gr_block { private: - trellis_metrics_c (const int O, const int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_c (int O, int D, const std::vector<gr_complex> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_f.cc b/gr-trellis/src/lib/trellis_metrics_f.cc index 2e148bbd5..69e4a99df 100644 --- a/gr-trellis/src/lib/trellis_metrics_f.cc +++ b/gr-trellis/src/lib/trellis_metrics_f.cc @@ -32,14 +32,14 @@ trellis_metrics_f_sptr -trellis_make_metrics_f (const int O, const int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE) +trellis_make_metrics_f (int O, int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE) { return trellis_metrics_f_sptr (new trellis_metrics_f (O,D,TABLE,TYPE)); } -trellis_metrics_f::trellis_metrics_f (const int O, const int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE) +trellis_metrics_f::trellis_metrics_f (int O, int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE) : gr_block ("metrics_f", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (float))), diff --git a/gr-trellis/src/lib/trellis_metrics_f.h b/gr-trellis/src/lib/trellis_metrics_f.h index b668c08d0..44a9152f9 100644 --- a/gr-trellis/src/lib/trellis_metrics_f.h +++ b/gr-trellis/src/lib/trellis_metrics_f.h @@ -31,7 +31,7 @@ class trellis_metrics_f; typedef boost::shared_ptr<trellis_metrics_f> trellis_metrics_f_sptr; -trellis_metrics_f_sptr trellis_make_metrics_f (const int O, const int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_f_sptr trellis_make_metrics_f (int O, int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -45,8 +45,8 @@ class trellis_metrics_f : public gr_block trellis_metric_type_t d_TYPE; std::vector<float> d_TABLE; - friend trellis_metrics_f_sptr trellis_make_metrics_f (const int O, const int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); - trellis_metrics_f (const int O, const int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); + friend trellis_metrics_f_sptr trellis_make_metrics_f (int O, int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_f (int O, int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_f.i b/gr-trellis/src/lib/trellis_metrics_f.i index e808af168..a0dac39f2 100644 --- a/gr-trellis/src/lib/trellis_metrics_f.i +++ b/gr-trellis/src/lib/trellis_metrics_f.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,metrics_f); -trellis_metrics_f_sptr trellis_make_metrics_f (const int O, const int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_f_sptr trellis_make_metrics_f (int O, int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); class trellis_metrics_f : public gr_block { private: - trellis_metrics_f (const int O, const int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_f (int O, int D, const std::vector<float> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_i.cc b/gr-trellis/src/lib/trellis_metrics_i.cc index 5901c5513..b0fa85fa0 100644 --- a/gr-trellis/src/lib/trellis_metrics_i.cc +++ b/gr-trellis/src/lib/trellis_metrics_i.cc @@ -32,14 +32,14 @@ trellis_metrics_i_sptr -trellis_make_metrics_i (const int O, const int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE) +trellis_make_metrics_i (int O, int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE) { return trellis_metrics_i_sptr (new trellis_metrics_i (O,D,TABLE,TYPE)); } -trellis_metrics_i::trellis_metrics_i (const int O, const int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE) +trellis_metrics_i::trellis_metrics_i (int O, int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE) : gr_block ("metrics_i", gr_make_io_signature (1, -1, sizeof (int)), gr_make_io_signature (1, -1, sizeof (float))), diff --git a/gr-trellis/src/lib/trellis_metrics_i.h b/gr-trellis/src/lib/trellis_metrics_i.h index c51e377e7..6e46eef60 100644 --- a/gr-trellis/src/lib/trellis_metrics_i.h +++ b/gr-trellis/src/lib/trellis_metrics_i.h @@ -31,7 +31,7 @@ class trellis_metrics_i; typedef boost::shared_ptr<trellis_metrics_i> trellis_metrics_i_sptr; -trellis_metrics_i_sptr trellis_make_metrics_i (const int O, const int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_i_sptr trellis_make_metrics_i (int O, int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -45,8 +45,8 @@ class trellis_metrics_i : public gr_block trellis_metric_type_t d_TYPE; std::vector<int> d_TABLE; - friend trellis_metrics_i_sptr trellis_make_metrics_i (const int O, const int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); - trellis_metrics_i (const int O, const int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); + friend trellis_metrics_i_sptr trellis_make_metrics_i (int O, int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_i (int O, int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_i.i b/gr-trellis/src/lib/trellis_metrics_i.i index dadd06577..5e217d1db 100644 --- a/gr-trellis/src/lib/trellis_metrics_i.i +++ b/gr-trellis/src/lib/trellis_metrics_i.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,metrics_i); -trellis_metrics_i_sptr trellis_make_metrics_i (const int O, const int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_i_sptr trellis_make_metrics_i (int O, int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); class trellis_metrics_i : public gr_block { private: - trellis_metrics_i (const int O, const int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_i (int O, int D, const std::vector<int> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_s.cc b/gr-trellis/src/lib/trellis_metrics_s.cc index 3bee2cc92..07b409726 100644 --- a/gr-trellis/src/lib/trellis_metrics_s.cc +++ b/gr-trellis/src/lib/trellis_metrics_s.cc @@ -32,14 +32,14 @@ trellis_metrics_s_sptr -trellis_make_metrics_s (const int O, const int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE) +trellis_make_metrics_s (int O, int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE) { return trellis_metrics_s_sptr (new trellis_metrics_s (O,D,TABLE,TYPE)); } -trellis_metrics_s::trellis_metrics_s (const int O, const int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE) +trellis_metrics_s::trellis_metrics_s (int O, int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE) : gr_block ("metrics_s", gr_make_io_signature (1, -1, sizeof (short)), gr_make_io_signature (1, -1, sizeof (float))), diff --git a/gr-trellis/src/lib/trellis_metrics_s.h b/gr-trellis/src/lib/trellis_metrics_s.h index b4332bcc3..abd027e50 100644 --- a/gr-trellis/src/lib/trellis_metrics_s.h +++ b/gr-trellis/src/lib/trellis_metrics_s.h @@ -31,7 +31,7 @@ class trellis_metrics_s; typedef boost::shared_ptr<trellis_metrics_s> trellis_metrics_s_sptr; -trellis_metrics_s_sptr trellis_make_metrics_s (const int O, const int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_s_sptr trellis_make_metrics_s (int O, int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -45,8 +45,8 @@ class trellis_metrics_s : public gr_block trellis_metric_type_t d_TYPE; std::vector<short> d_TABLE; - friend trellis_metrics_s_sptr trellis_make_metrics_s (const int O, const int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); - trellis_metrics_s (const int O, const int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); + friend trellis_metrics_s_sptr trellis_make_metrics_s (int O, int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_s (int O, int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_metrics_s.i b/gr-trellis/src/lib/trellis_metrics_s.i index d7529a3e1..86830f778 100644 --- a/gr-trellis/src/lib/trellis_metrics_s.i +++ b/gr-trellis/src/lib/trellis_metrics_s.i @@ -24,12 +24,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,metrics_s); -trellis_metrics_s_sptr trellis_make_metrics_s (const int O, const int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); +trellis_metrics_s_sptr trellis_make_metrics_s (int O, int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); class trellis_metrics_s : public gr_block { private: - trellis_metrics_s (const int O, const int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); + trellis_metrics_s (int O, int D, const std::vector<short> &TABLE, trellis_metric_type_t TYPE); public: int O () const { return d_O; } diff --git a/gr-trellis/src/lib/trellis_permutation.cc b/gr-trellis/src/lib/trellis_permutation.cc index 78bdbaf46..88e546a49 100644 --- a/gr-trellis/src/lib/trellis_permutation.cc +++ b/gr-trellis/src/lib/trellis_permutation.cc @@ -29,20 +29,21 @@ #include <iostream> trellis_permutation_sptr -trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES) +trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT) { - return trellis_permutation_sptr (new trellis_permutation (K,TABLE,NBYTES)); + return trellis_permutation_sptr (new trellis_permutation (K,TABLE,SYMS_PER_BLOCK,NBYTES_INOUT)); } -trellis_permutation::trellis_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES) +trellis_permutation::trellis_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT) : gr_sync_block ("permutation", - gr_make_io_signature (1, -1, NBYTES), - gr_make_io_signature (1, -1, NBYTES)), + gr_make_io_signature (1, -1, NBYTES_INOUT), + gr_make_io_signature (1, -1, NBYTES_INOUT)), d_K (K), d_TABLE (TABLE), - d_NBYTES (NBYTES) + d_SYMS_PER_BLOCK (SYMS_PER_BLOCK), + d_NBYTES_INOUT (NBYTES_INOUT) { - set_output_multiple (d_K); + set_output_multiple (d_K*SYMS_PER_BLOCK); //std::cout << d_K << "\n"; } @@ -56,16 +57,23 @@ trellis_permutation::work (int noutput_items, int nstreams = input_items.size(); assert (input_items.size() == output_items.size()); assert (noutput_items % d_K ==0); - //std::cout << noutput_items << "\n"; for (int m=0;m<nstreams;m++) { const char *in = (const char *) input_items[m]; char *out = (char *) output_items[m]; // per stream processing - for (unsigned int i = 0; i < noutput_items; i++){ - //std::cout << i << " " << i*d_NBYTES << " " << (d_K*(i/d_K)+d_TABLE[i%d_K])*d_NBYTES << "\n"; - memcpy(&(out[i*d_NBYTES]), &(in[(d_K*(i/d_K)+d_TABLE[i%d_K])*d_NBYTES]), d_NBYTES); + for (int i = 0; i < noutput_items/d_SYMS_PER_BLOCK; i++){ + // Index i refers to blocks. + // Begining of packet (in blocks) + int i0 = d_K*(i/d_K); + // position of block within packet (in blocks) + int j0 = i%d_K; + // new position of block within packet (in blocks) + int k0 = d_TABLE[j0]; + memcpy(&(out[i*d_SYMS_PER_BLOCK*d_NBYTES_INOUT]), + &(in[(i0+k0)*d_SYMS_PER_BLOCK*d_NBYTES_INOUT]), + d_NBYTES_INOUT*d_SYMS_PER_BLOCK); } // end per stream processing } diff --git a/gr-trellis/src/lib/trellis_permutation.h b/gr-trellis/src/lib/trellis_permutation.h index 815ed3976..39c5b7c9c 100644 --- a/gr-trellis/src/lib/trellis_permutation.h +++ b/gr-trellis/src/lib/trellis_permutation.h @@ -30,7 +30,7 @@ class trellis_permutation; typedef boost::shared_ptr<trellis_permutation> trellis_permutation_sptr; -trellis_permutation_sptr trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES); +trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT); /*! * \brief Permutation. @@ -41,16 +41,18 @@ trellis_permutation_sptr trellis_make_permutation (const int K, const std::vecto class trellis_permutation : public gr_sync_block { private: - friend trellis_permutation_sptr trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES); + friend trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT); int d_K; std::vector<int> d_TABLE; - size_t d_NBYTES; - trellis_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES); + int d_SYMS_PER_BLOCK; + size_t d_NBYTES_INOUT; + trellis_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES); public: int K () const { return d_K; } const std::vector<int> & TABLE () const { return d_TABLE; } - size_t NBYTES () const { return d_NBYTES; } + int SYMS_PER_BLOCK () const { return d_SYMS_PER_BLOCK; } + size_t NBYTES_INOUT () const { return d_NBYTES_INOUT; } int work (int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-trellis/src/lib/trellis_permutation.i b/gr-trellis/src/lib/trellis_permutation.i index db74cdf05..4dbb92bea 100644 --- a/gr-trellis/src/lib/trellis_permutation.i +++ b/gr-trellis/src/lib/trellis_permutation.i @@ -22,18 +22,20 @@ GR_SWIG_BLOCK_MAGIC(trellis,permutation); -trellis_permutation_sptr trellis_make_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES); +trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT); class trellis_permutation : public gr_sync_block { private: int d_K; std::vector<int> d_TABLE; - size_t d_NBYTES; - trellis_permutation (const int K, const std::vector<int> &TABLE, const size_t NBYTES); + int d_SYMS_PER_BLOCK; + size_t d_NBYTES_INOUT; + trellis_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT); public: int K () const { return d_K; } const std::vector<int> & TABLE () const { return d_TABLE; } - size_t NBYTES () const { return d_NBYTES; } + int SYMS_PER_BLOCK () const { return d_SYMS_PER_BLOCK; } + size_t NBYTES_INOUT () const { return d_NBYTES_INOUT; } }; diff --git a/gr-trellis/src/lib/trellis_siso_f.cc b/gr-trellis/src/lib/trellis_siso_f.cc new file mode 100644 index 000000000..df364fc65 --- /dev/null +++ b/gr-trellis/src/lib/trellis_siso_f.cc @@ -0,0 +1,323 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * 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) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <trellis_siso_f.h> +#include <gr_io_signature.h> +#include <stdexcept> +#include <assert.h> +#include <iostream> + +static const float INF = 1.0e9; + +trellis_siso_f_sptr +trellis_make_siso_f ( + const fsm &FSM, + int K, + int S0, + int SK, + bool POSTI, + bool POSTO, + trellis_siso_type_t SISO_TYPE) +{ + return trellis_siso_f_sptr (new trellis_siso_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE)); +} + +trellis_siso_f::trellis_siso_f ( + const fsm &FSM, + int K, + int S0, + int SK, + bool POSTI, + bool POSTO, + trellis_siso_type_t SISO_TYPE) + : gr_block ("siso_f", + gr_make_io_signature (1, -1, sizeof (float)), + gr_make_io_signature (1, -1, sizeof (float))), + d_FSM (FSM), + d_K (K), + d_S0 (S0), + d_SK (SK), + d_POSTI (POSTI), + d_POSTO (POSTO), + d_SISO_TYPE (SISO_TYPE), + d_alpha(FSM.S()*(K+1)), + d_beta(FSM.S()*(K+1)) +{ + int multiple; + if (d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + //printf("constructor: Multiple = %d\n",multiple); + set_output_multiple (d_K*multiple); + //what is the meaning of relative rate for this? + // it was suggested to use the one furthest from 1.0 + // let's do it. + set_relative_rate ( multiple / ((double) d_FSM.I()) ); +} + + +void +trellis_siso_f::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + int multiple; + if (d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + //printf("forecast: Multiple = %d\n",multiple); + assert (noutput_items % (d_K*multiple) == 0); + int input_required1 = d_FSM.I() * (noutput_items/multiple) ; + int input_required2 = d_FSM.O() * (noutput_items/multiple) ; + //printf("forecast: Output requirements: %d\n",noutput_items); + //printf("forecast: Input requirements: %d %d\n",input_required1,input_required2); + unsigned ninputs = ninput_items_required.size(); + assert(ninputs % 2 == 0); + for (unsigned int i = 0; i < ninputs/2; i++) { + ninput_items_required[2*i] = input_required1; + ninput_items_required[2*i+1] = input_required2; + } +} + +inline float min(float a, float b) +{ + return a <= b ? a : b; +} + +inline float min_star(float a, float b) +{ + return (a <= b ? a : b)-log(1+exp(a <= b ? a-b : b-a)); +} + +void siso_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, + int K, + int S0,int SK, + bool POSTI, bool POSTO, + float (*p2mymin)(float,float), + const float *priori, const float *prioro, float *post, + std::vector<float> &alpha, + std::vector<float> &beta) +{ + float norm,mm,minm; + + + if(S0<0) { // initial state not specified + for(int i=0;i<S;i++) alpha[0*S+i]=0; + } + else { + for(int i=0;i<S;i++) alpha[0*S+i]=INF; + alpha[0*S+S0]=0.0; + } + + for(int k=0;k<K;k++) { // forward recursion + norm=INF; + for(int j=0;j<S;j++) { + minm=INF; + for(int i=0;i<I;i++) { + int i0 = j*I+i; + mm=alpha[k*S+PS[i0]]+priori[k*I+PI[i0]]+prioro[k*O+OS[PS[i0]*I+PI[i0]]]; + minm=(*p2mymin)(minm,mm); + } + alpha[(k+1)*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + alpha[(k+1)*S+j]-=norm; // normalize total metrics so they do not explode + } + + if(SK<0) { // final state not specified + for(int i=0;i<S;i++) beta[K*S+i]=0; + } + else { + for(int i=0;i<S;i++) beta[K*S+i]=INF; + beta[K*S+SK]=0.0; + } + + for(int k=K-1;k>=0;k--) { // backward recursion + norm=INF; + for(int j=0;j<S;j++) { + minm=INF; + for(int i=0;i<I;i++) { + int i0 = j*I+i; + mm=beta[(k+1)*S+NS[i0]]+priori[k*I+i]+prioro[k*O+OS[i0]]; + minm=(*p2mymin)(minm,mm); + } + beta[k*S+j]=minm; + if(minm<norm) norm=minm; + } + for(int j=0;j<S;j++) + beta[k*S+j]-=norm; // normalize total metrics so they do not explode + } + + +if (POSTI && POSTO) +{ + for(int k=0;k<K;k++) { // input combining + norm=INF; + for(int i=0;i<I;i++) { + minm=INF; + for(int j=0;j<S;j++) { + mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; + minm=(*p2mymin)(minm,mm); + } + post[k*(I+O)+i]=minm; + if(minm<norm) norm=minm; + } + for(int i=0;i<I;i++) + post[k*(I+O)+i]-=norm; // normalize metrics + } + + + for(int k=0;k<K;k++) { // output combining + norm=INF; + for(int n=0;n<O;n++) { + minm=INF; + for(int j=0;j<S;j++) { + for(int i=0;i<I;i++) { + mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); + minm=(*p2mymin)(minm,mm); + } + } + post[k*(I+O)+I+n]=minm; + if(minm<norm) norm=minm; + } + for(int n=0;n<O;n++) + post[k*(I+O)+I+n]-=norm; // normalize metrics + } +} +else if(POSTI) +{ + for(int k=0;k<K;k++) { // input combining + norm=INF; + for(int i=0;i<I;i++) { + minm=INF; + for(int j=0;j<S;j++) { + mm=alpha[k*S+j]+prioro[k*O+OS[j*I+i]]+beta[(k+1)*S+NS[j*I+i]]; + minm=(*p2mymin)(minm,mm); + } + post[k*I+i]=minm; + if(minm<norm) norm=minm; + } + for(int i=0;i<I;i++) + post[k*I+i]-=norm; // normalize metrics + } +} +else if(POSTO) +{ + for(int k=0;k<K;k++) { // output combining + norm=INF; + for(int n=0;n<O;n++) { + minm=INF; + for(int j=0;j<S;j++) { + for(int i=0;i<I;i++) { + mm= (n==OS[j*I+i] ? alpha[k*S+j]+priori[k*I+i]+beta[(k+1)*S+NS[j*I+i]] : INF); + minm=(*p2mymin)(minm,mm); + } + } + post[k*O+n]=minm; + if(minm<norm) norm=minm; + } + for(int n=0;n<O;n++) + post[k*O+n]-=norm; // normalize metrics + } +} +else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + +} + + + + + + +int +trellis_siso_f::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + assert (input_items.size() == 2*output_items.size()); + int nstreams = output_items.size(); + //printf("general_work:Streams: %d\n",nstreams); + int multiple; + if (d_POSTI && d_POSTO) + multiple = d_FSM.I()+d_FSM.O(); + else if(d_POSTI) + multiple = d_FSM.I(); + else if(d_POSTO) + multiple = d_FSM.O(); + else + throw std::runtime_error ("Not both POSTI and POSTO can be false."); + + assert (noutput_items % (d_K*multiple) == 0); + int nblocks = noutput_items / (d_K*multiple); + //printf("general_work:Blocks: %d\n",nblocks); + //for(int i=0;i<ninput_items.size();i++) + //printf("general_work:Input items available: %d\n",ninput_items[i]); + + float (*p2min)(float, float) = NULL; + if(d_SISO_TYPE == TRELLIS_MIN_SUM) + p2min = &min; + else if(d_SISO_TYPE == TRELLIS_SUM_PRODUCT) + p2min = &min_star; + + + for (int m=0;m<nstreams;m++) { + const float *in1 = (const float *) input_items[2*m]; + const float *in2 = (const float *) input_items[2*m+1]; + float *out = (float *) output_items[m]; + for (int n=0;n<nblocks;n++) { + siso_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, + d_POSTI,d_POSTO, + p2min, + &(in1[n*d_K*d_FSM.I()]),&(in2[n*d_K*d_FSM.O()]), + &(out[n*d_K*multiple]), + d_alpha,d_beta); + } + } + + for (unsigned int i = 0; i < input_items.size()/2; i++) { + consume(2*i,d_FSM.I() * noutput_items / multiple ); + consume(2*i+1,d_FSM.O() * noutput_items / multiple ); + } + + return noutput_items; +} diff --git a/gr-trellis/src/lib/trellis_siso_f.h b/gr-trellis/src/lib/trellis_siso_f.h new file mode 100644 index 000000000..36981254d --- /dev/null +++ b/gr-trellis/src/lib/trellis_siso_f.h @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * 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) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ + +#ifndef INCLUDED_TRELLIS_SISO_F_H +#define INCLUDED_TRELLIS_SISO_F_H + +#include "fsm.h" +#include "trellis_siso_type.h" +#include <gr_block.h> + +class trellis_siso_f; +typedef boost::shared_ptr<trellis_siso_f> trellis_siso_f_sptr; + +trellis_siso_f_sptr trellis_make_siso_f ( + const fsm &FSM, + int K, + int S0, + int SK, + bool POSTI, + bool POSTO, + trellis_siso_type_t d_SISO_TYPE); + + + +class trellis_siso_f : public gr_block +{ + fsm d_FSM; + int d_K; + int d_S0; + int d_SK; + bool d_POSTI; + bool d_POSTO; + trellis_siso_type_t d_SISO_TYPE; + std::vector<float> d_alpha; + std::vector<float> d_beta; + + friend trellis_siso_f_sptr trellis_make_siso_f ( + const fsm &FSM, + int K, + int S0, + int SK, + bool POSTI, + bool POSTO, + trellis_siso_type_t d_SISO_TYPE); + + + trellis_siso_f ( + const fsm &FSM, + int K, + int S0, + int SK, + bool POSTI, + bool POSTO, + trellis_siso_type_t d_SISO_TYPE); + + +public: + fsm FSM () const { return d_FSM; } + int K () const { return d_K; } + int S0 () const { return d_S0; } + int SK () const { return d_SK; } + bool POSTI () const { return d_POSTI; } + bool POSTO () const { return d_POSTO; } + trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } + void forecast (int noutput_items, + gr_vector_int &ninput_items_required); + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gr-trellis/src/lib/trellis_siso_f.i b/gr-trellis/src/lib/trellis_siso_f.i new file mode 100644 index 000000000..534ac3897 --- /dev/null +++ b/gr-trellis/src/lib/trellis_siso_f.i @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * 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) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ + +GR_SWIG_BLOCK_MAGIC(trellis,siso_f); + +trellis_siso_f_sptr trellis_make_siso_f ( + const fsm &FSM, + int K, + int S0, + int SK, + bool POSTI, + bool POSTO, + trellis_siso_type_t SISO_TYPE); + + +class trellis_siso_f : public gr_block +{ +private: + trellis_siso_f ( + const fsm &FSM, + int K, + int S0, + int SK, + bool POSTI, + bool POSTO, + trellis_siso_type_t SISO_TYPE); + +public: + fsm FSM () const { return d_FSM; } + int K () const { return d_K; } + int S0 () const { return d_S0; } + int SK () const { return d_SK; } + bool POSTI () const { return d_POSTI; } + bool POSTO () const { return d_POSTO; } + trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } +}; diff --git a/gr-trellis/src/lib/trellis_siso_f.lo b/gr-trellis/src/lib/trellis_siso_f.lo new file mode 100644 index 000000000..2d24f85b0 --- /dev/null +++ b/gr-trellis/src/lib/trellis_siso_f.lo @@ -0,0 +1,12 @@ +# trellis_siso_f.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.6 (1.1220.2.95 2004/04/11 05:50:42) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/trellis_siso_f.o' + +# Name of the non-PIC object. +non_pic_object=none + diff --git a/gr-trellis/src/lib/trellis_siso_type.h b/gr-trellis/src/lib/trellis_siso_type.h new file mode 100644 index 000000000..6f727522a --- /dev/null +++ b/gr-trellis/src/lib/trellis_siso_type.h @@ -0,0 +1,31 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * 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) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ + +#ifndef INCLUDED_TRELLIS_SISO_TYPE_H +#define INCLUDED_TRELLIS_SISO_TYPE_H + +typedef enum { + TRELLIS_MIN_SUM = 200, TRELLIS_SUM_PRODUCT +} trellis_siso_type_t; + +#endif + diff --git a/gr-trellis/src/lib/trellis_viterbi_X.cc.t b/gr-trellis/src/lib/trellis_viterbi_X.cc.t index 0ab423b0a..8f02320d6 100644 --- a/gr-trellis/src/lib/trellis_viterbi_X.cc.t +++ b/gr-trellis/src/lib/trellis_viterbi_X.cc.t @@ -34,18 +34,18 @@ static const float INF = 1.0e9; @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) { return @SPTR_NAME@ (new @NAME@ (FSM,K,S0,SK)); } @NAME@::@NAME@ ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) : gr_block ("@BASE_NAME@", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (@TYPE@))), @@ -74,13 +74,13 @@ void -void viterbi_algorithm(const int I, const int S, const int O, +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 int K, - const int S0,const int SK, + int K, + int S0,int SK, const float *in, @TYPE@ *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_X.h.t b/gr-trellis/src/lib/trellis_viterbi_X.h.t index f1b8e0062..f06fdfdcd 100644 --- a/gr-trellis/src/lib/trellis_viterbi_X.h.t +++ b/gr-trellis/src/lib/trellis_viterbi_X.h.t @@ -33,9 +33,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); @@ -49,16 +49,16 @@ class @NAME@ : public gr_block friend @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); @NAME@ ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_X.i.t b/gr-trellis/src/lib/trellis_viterbi_X.i.t index 605251e4d..99d899b9b 100644 --- a/gr-trellis/src/lib/trellis_viterbi_X.i.t +++ b/gr-trellis/src/lib/trellis_viterbi_X.i.t @@ -26,9 +26,9 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); class @NAME@ : public gr_block @@ -36,9 +36,9 @@ class @NAME@ : public gr_block private: @NAME@ ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_viterbi_b.cc b/gr-trellis/src/lib/trellis_viterbi_b.cc index 2e005a316..ce2778aff 100644 --- a/gr-trellis/src/lib/trellis_viterbi_b.cc +++ b/gr-trellis/src/lib/trellis_viterbi_b.cc @@ -34,18 +34,18 @@ static const float INF = 1.0e9; trellis_viterbi_b_sptr trellis_make_viterbi_b ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) { return trellis_viterbi_b_sptr (new trellis_viterbi_b (FSM,K,S0,SK)); } trellis_viterbi_b::trellis_viterbi_b ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) : gr_block ("viterbi_b", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (unsigned char))), @@ -74,13 +74,13 @@ trellis_viterbi_b::forecast (int noutput_items, gr_vector_int &ninput_items_requ -void viterbi_algorithm(const int I, const int S, const int O, +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 int K, - const int S0,const int SK, + int K, + int S0,int SK, const float *in, unsigned char *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_b.h b/gr-trellis/src/lib/trellis_viterbi_b.h index a4fa533e8..c1c359b12 100644 --- a/gr-trellis/src/lib/trellis_viterbi_b.h +++ b/gr-trellis/src/lib/trellis_viterbi_b.h @@ -33,9 +33,9 @@ typedef boost::shared_ptr<trellis_viterbi_b> trellis_viterbi_b_sptr; trellis_viterbi_b_sptr trellis_make_viterbi_b ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); @@ -49,16 +49,16 @@ class trellis_viterbi_b : public gr_block friend trellis_viterbi_b_sptr trellis_make_viterbi_b ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); trellis_viterbi_b ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_b.i b/gr-trellis/src/lib/trellis_viterbi_b.i index 44fca365b..8f456b0bb 100644 --- a/gr-trellis/src/lib/trellis_viterbi_b.i +++ b/gr-trellis/src/lib/trellis_viterbi_b.i @@ -26,9 +26,9 @@ GR_SWIG_BLOCK_MAGIC(trellis,viterbi_b); trellis_viterbi_b_sptr trellis_make_viterbi_b ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); class trellis_viterbi_b : public gr_block @@ -36,9 +36,9 @@ class trellis_viterbi_b : public gr_block private: trellis_viterbi_b ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t b/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t index 52e01026b..de2079ad0 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t @@ -34,24 +34,24 @@ static const float INF = 1.0e9; @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) { return @SPTR_NAME@ (new @NAME@ (FSM,D,TABLE,K,S0,SK,TYPE)); } @NAME@::@NAME@ ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) : gr_block ("@BASE_NAME@", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (@TYPE@))), @@ -83,16 +83,16 @@ void -void viterbi_algorithm_combined(const int I, const int S, const int O, +void viterbi_algorithm_combined(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 int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0,const int SK, - const trellis_metric_type_t TYPE, + int K, + int S0,int SK, + trellis_metric_type_t TYPE, const float *in, @TYPE@ *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_X.h.t b/gr-trellis/src/lib/trellis_viterbi_combined_X.h.t index 8d7059a55..14f565202 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_X.h.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_X.h.t @@ -34,12 +34,12 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class @NAME@ : public gr_block @@ -55,22 +55,22 @@ class @NAME@ : public gr_block friend @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); @NAME@ ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_X.i.t b/gr-trellis/src/lib/trellis_viterbi_combined_X.i.t index 388e0626e..e4b68402c 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_X.i.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_X.i.t @@ -26,12 +26,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); @SPTR_NAME@ trellis_make_@BASE_NAME@ ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class @NAME@ : public gr_block @@ -39,12 +39,12 @@ class @NAME@ : public gr_block private: @NAME@ ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_b.cc b/gr-trellis/src/lib/trellis_viterbi_combined_b.cc index 8c72b2a3c..2d245f58b 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_b.cc +++ b/gr-trellis/src/lib/trellis_viterbi_combined_b.cc @@ -34,24 +34,24 @@ static const float INF = 1.0e9; trellis_viterbi_combined_b_sptr trellis_make_viterbi_combined_b ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) { return trellis_viterbi_combined_b_sptr (new trellis_viterbi_combined_b (FSM,D,TABLE,K,S0,SK,TYPE)); } trellis_viterbi_combined_b::trellis_viterbi_combined_b ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) : gr_block ("viterbi_combined_b", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (unsigned char))), @@ -83,16 +83,16 @@ trellis_viterbi_combined_b::forecast (int noutput_items, gr_vector_int &ninput_i -void viterbi_algorithm_combined(const int I, const int S, const int O, +void viterbi_algorithm_combined(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 int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0,const int SK, - const trellis_metric_type_t TYPE, + int K, + int S0,int SK, + trellis_metric_type_t TYPE, const float *in, unsigned char *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_b.h b/gr-trellis/src/lib/trellis_viterbi_combined_b.h index f523c5ce1..5de0924d7 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_b.h +++ b/gr-trellis/src/lib/trellis_viterbi_combined_b.h @@ -34,12 +34,12 @@ typedef boost::shared_ptr<trellis_viterbi_combined_b> trellis_viterbi_combined_b trellis_viterbi_combined_b_sptr trellis_make_viterbi_combined_b ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class trellis_viterbi_combined_b : public gr_block @@ -55,22 +55,22 @@ class trellis_viterbi_combined_b : public gr_block friend trellis_viterbi_combined_b_sptr trellis_make_viterbi_combined_b ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); trellis_viterbi_combined_b ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_b.i b/gr-trellis/src/lib/trellis_viterbi_combined_b.i index 44b4aa431..069860893 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_b.i +++ b/gr-trellis/src/lib/trellis_viterbi_combined_b.i @@ -26,12 +26,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,viterbi_combined_b); trellis_viterbi_combined_b_sptr trellis_make_viterbi_combined_b ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class trellis_viterbi_combined_b : public gr_block @@ -39,12 +39,12 @@ class trellis_viterbi_combined_b : public gr_block private: trellis_viterbi_combined_b ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_i.cc b/gr-trellis/src/lib/trellis_viterbi_combined_i.cc index 3301d0283..4506fd127 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_i.cc +++ b/gr-trellis/src/lib/trellis_viterbi_combined_i.cc @@ -34,24 +34,24 @@ static const float INF = 1.0e9; trellis_viterbi_combined_i_sptr trellis_make_viterbi_combined_i ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) { return trellis_viterbi_combined_i_sptr (new trellis_viterbi_combined_i (FSM,D,TABLE,K,S0,SK,TYPE)); } trellis_viterbi_combined_i::trellis_viterbi_combined_i ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) : gr_block ("viterbi_combined_i", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (int))), @@ -83,16 +83,16 @@ trellis_viterbi_combined_i::forecast (int noutput_items, gr_vector_int &ninput_i -void viterbi_algorithm_combined(const int I, const int S, const int O, +void viterbi_algorithm_combined(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 int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0,const int SK, - const trellis_metric_type_t TYPE, + int K, + int S0,int SK, + trellis_metric_type_t TYPE, const float *in, int *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_i.h b/gr-trellis/src/lib/trellis_viterbi_combined_i.h index 171fcb93d..1ac5d7d1d 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_i.h +++ b/gr-trellis/src/lib/trellis_viterbi_combined_i.h @@ -34,12 +34,12 @@ typedef boost::shared_ptr<trellis_viterbi_combined_i> trellis_viterbi_combined_i trellis_viterbi_combined_i_sptr trellis_make_viterbi_combined_i ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class trellis_viterbi_combined_i : public gr_block @@ -55,22 +55,22 @@ class trellis_viterbi_combined_i : public gr_block friend trellis_viterbi_combined_i_sptr trellis_make_viterbi_combined_i ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); trellis_viterbi_combined_i ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_i.i b/gr-trellis/src/lib/trellis_viterbi_combined_i.i index 4b8355e0e..05d68d580 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_i.i +++ b/gr-trellis/src/lib/trellis_viterbi_combined_i.i @@ -26,12 +26,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,viterbi_combined_i); trellis_viterbi_combined_i_sptr trellis_make_viterbi_combined_i ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class trellis_viterbi_combined_i : public gr_block @@ -39,12 +39,12 @@ class trellis_viterbi_combined_i : public gr_block private: trellis_viterbi_combined_i ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_s.cc b/gr-trellis/src/lib/trellis_viterbi_combined_s.cc index 46dda3d1d..f103db229 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_s.cc +++ b/gr-trellis/src/lib/trellis_viterbi_combined_s.cc @@ -34,24 +34,24 @@ static const float INF = 1.0e9; trellis_viterbi_combined_s_sptr trellis_make_viterbi_combined_s ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) { return trellis_viterbi_combined_s_sptr (new trellis_viterbi_combined_s (FSM,D,TABLE,K,S0,SK,TYPE)); } trellis_viterbi_combined_s::trellis_viterbi_combined_s ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE) + int K, + int S0, + int SK, + trellis_metric_type_t TYPE) : gr_block ("viterbi_combined_s", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (short))), @@ -83,16 +83,16 @@ trellis_viterbi_combined_s::forecast (int noutput_items, gr_vector_int &ninput_i -void viterbi_algorithm_combined(const int I, const int S, const int O, +void viterbi_algorithm_combined(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 int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0,const int SK, - const trellis_metric_type_t TYPE, + int K, + int S0,int SK, + trellis_metric_type_t TYPE, const float *in, short *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_s.h b/gr-trellis/src/lib/trellis_viterbi_combined_s.h index 5b74b35a9..c174c5f01 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_s.h +++ b/gr-trellis/src/lib/trellis_viterbi_combined_s.h @@ -34,12 +34,12 @@ typedef boost::shared_ptr<trellis_viterbi_combined_s> trellis_viterbi_combined_s trellis_viterbi_combined_s_sptr trellis_make_viterbi_combined_s ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class trellis_viterbi_combined_s : public gr_block @@ -55,22 +55,22 @@ class trellis_viterbi_combined_s : public gr_block friend trellis_viterbi_combined_s_sptr trellis_make_viterbi_combined_s ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); trellis_viterbi_combined_s ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_s.i b/gr-trellis/src/lib/trellis_viterbi_combined_s.i index ddac52692..c1d5693a2 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_s.i +++ b/gr-trellis/src/lib/trellis_viterbi_combined_s.i @@ -26,12 +26,12 @@ GR_SWIG_BLOCK_MAGIC(trellis,viterbi_combined_s); trellis_viterbi_combined_s_sptr trellis_make_viterbi_combined_s ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); class trellis_viterbi_combined_s : public gr_block @@ -39,12 +39,12 @@ class trellis_viterbi_combined_s : public gr_block private: trellis_viterbi_combined_s ( const fsm &FSM, - const int D, + int D, const std::vector<float> &TABLE, - const int K, - const int S0, - const int SK, - const trellis_metric_type_t TYPE); + int K, + int S0, + int SK, + trellis_metric_type_t TYPE); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_viterbi_i.cc b/gr-trellis/src/lib/trellis_viterbi_i.cc index 58a39f6e5..2ff304ebb 100644 --- a/gr-trellis/src/lib/trellis_viterbi_i.cc +++ b/gr-trellis/src/lib/trellis_viterbi_i.cc @@ -34,18 +34,18 @@ static const float INF = 1.0e9; trellis_viterbi_i_sptr trellis_make_viterbi_i ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) { return trellis_viterbi_i_sptr (new trellis_viterbi_i (FSM,K,S0,SK)); } trellis_viterbi_i::trellis_viterbi_i ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) : gr_block ("viterbi_i", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (int))), @@ -74,13 +74,13 @@ trellis_viterbi_i::forecast (int noutput_items, gr_vector_int &ninput_items_requ -void viterbi_algorithm(const int I, const int S, const int O, +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 int K, - const int S0,const int SK, + int K, + int S0,int SK, const float *in, int *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_i.h b/gr-trellis/src/lib/trellis_viterbi_i.h index 5da0a3866..86ac89876 100644 --- a/gr-trellis/src/lib/trellis_viterbi_i.h +++ b/gr-trellis/src/lib/trellis_viterbi_i.h @@ -33,9 +33,9 @@ typedef boost::shared_ptr<trellis_viterbi_i> trellis_viterbi_i_sptr; trellis_viterbi_i_sptr trellis_make_viterbi_i ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); @@ -49,16 +49,16 @@ class trellis_viterbi_i : public gr_block friend trellis_viterbi_i_sptr trellis_make_viterbi_i ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); trellis_viterbi_i ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_i.i b/gr-trellis/src/lib/trellis_viterbi_i.i index de402e36d..3b99f3173 100644 --- a/gr-trellis/src/lib/trellis_viterbi_i.i +++ b/gr-trellis/src/lib/trellis_viterbi_i.i @@ -26,9 +26,9 @@ GR_SWIG_BLOCK_MAGIC(trellis,viterbi_i); trellis_viterbi_i_sptr trellis_make_viterbi_i ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); class trellis_viterbi_i : public gr_block @@ -36,9 +36,9 @@ class trellis_viterbi_i : public gr_block private: trellis_viterbi_i ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: fsm FSM () const { return d_FSM; } diff --git a/gr-trellis/src/lib/trellis_viterbi_s.cc b/gr-trellis/src/lib/trellis_viterbi_s.cc index f5a0705c2..bb3dafa61 100644 --- a/gr-trellis/src/lib/trellis_viterbi_s.cc +++ b/gr-trellis/src/lib/trellis_viterbi_s.cc @@ -34,18 +34,18 @@ static const float INF = 1.0e9; trellis_viterbi_s_sptr trellis_make_viterbi_s ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) { return trellis_viterbi_s_sptr (new trellis_viterbi_s (FSM,K,S0,SK)); } trellis_viterbi_s::trellis_viterbi_s ( const fsm &FSM, - const int K, - const int S0, - const int SK) + int K, + int S0, + int SK) : gr_block ("viterbi_s", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (short))), @@ -74,13 +74,13 @@ trellis_viterbi_s::forecast (int noutput_items, gr_vector_int &ninput_items_requ -void viterbi_algorithm(const int I, const int S, const int O, +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 int K, - const int S0,const int SK, + int K, + int S0,int SK, const float *in, short *out, std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_s.h b/gr-trellis/src/lib/trellis_viterbi_s.h index 2c3a61c9b..6232ce5bf 100644 --- a/gr-trellis/src/lib/trellis_viterbi_s.h +++ b/gr-trellis/src/lib/trellis_viterbi_s.h @@ -33,9 +33,9 @@ typedef boost::shared_ptr<trellis_viterbi_s> trellis_viterbi_s_sptr; trellis_viterbi_s_sptr trellis_make_viterbi_s ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); @@ -49,16 +49,16 @@ class trellis_viterbi_s : public gr_block friend trellis_viterbi_s_sptr trellis_make_viterbi_s ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); trellis_viterbi_s ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: diff --git a/gr-trellis/src/lib/trellis_viterbi_s.i b/gr-trellis/src/lib/trellis_viterbi_s.i index 44e437265..99b14db78 100644 --- a/gr-trellis/src/lib/trellis_viterbi_s.i +++ b/gr-trellis/src/lib/trellis_viterbi_s.i @@ -26,9 +26,9 @@ GR_SWIG_BLOCK_MAGIC(trellis,viterbi_s); trellis_viterbi_s_sptr trellis_make_viterbi_s ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); class trellis_viterbi_s : public gr_block @@ -36,9 +36,9 @@ class trellis_viterbi_s : public gr_block private: trellis_viterbi_s ( const fsm &FSM, - const int K, - const int S0, - const int SK); + int K, + int S0, + int SK); public: fsm FSM () const { return d_FSM; } |