[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4379 - in gnuradio/branches/developers/michaelld/t29:
From: |
michaelld |
Subject: |
[Commit-gnuradio] r4379 - in gnuradio/branches/developers/michaelld/t29: gnuradio-examples/python/channel-coding/fsm_files gr-trellis/src/lib gr-trellis/src/python |
Date: |
Mon, 5 Feb 2007 07:46:05 -0700 (MST) |
Author: michaelld
Date: 2007-02-05 07:46:05 -0700 (Mon, 05 Feb 2007)
New Revision: 4379
Added:
gnuradio/branches/developers/michaelld/t29/gnuradio-examples/python/channel-coding/fsm_files/irregular.fsm
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils.py
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils_codes.py
Removed:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/build_utils.py
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/build_utils_codes.py
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/Makefile.am
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.h
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.i
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_combined_f.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_f.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_X.cc.t
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_b.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_b.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_i.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_s.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_i.cc
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_s.cc
Log:
Merge with the latest SVN changes.
Hopefully corrected "make distcheck" issue.
Places extra PY files in the src/python directory, where they belong.
Copied:
gnuradio/branches/developers/michaelld/t29/gnuradio-examples/python/channel-coding/fsm_files/irregular.fsm
(from rev 4378,
gnuradio/trunk/gnuradio-examples/python/channel-coding/fsm_files/irregular.fsm)
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gnuradio-examples/python/channel-coding/fsm_files/irregular.fsm
(rev 0)
+++
gnuradio/branches/developers/michaelld/t29/gnuradio-examples/python/channel-coding/fsm_files/irregular.fsm
2007-02-05 14:46:05 UTC (rev 4379)
@@ -0,0 +1,11 @@
+2 2 2
+
+0 0
+0 1
+
+0 1
+0 1
+
+
+useless irregular FSM for testing. state 0 has 3 incoming edges and state
+1 has 1 incoming edge.
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/Makefile.am
2007-02-05 07:15:51 UTC (rev 4378)
+++ gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/Makefile.am
2007-02-05 14:46:05 UTC (rev 4379)
@@ -54,7 +54,7 @@
include Makefile.gen
$(GENERATED_H) $(GENERATED_I) $(GENERATED_CC): $(CODE_GENERATOR)
- PYTHONPATH=$(top_srcdir)/gnuradio-core/src/python srcdir=$(srcdir) \
+ PYTHONPATH=$(top_srcdir)/gr-trellis/src/python srcdir=$(srcdir) \
$(PYTHON) $(srcdir)/generate_all.py
BUILT_SOURCES = \
@@ -74,6 +74,9 @@
LOCAL_IFILES = \
$(top_srcdir)/gr-trellis/src/lib/trellis.i
+EXTRA_DIST = \
+ $(CODE_GENERATOR)
+
# These files are built by SWIG. The first is the C++ glue.
# The second is the python wrapper that loads the _trellis shared library
# and knows how to call our extensions.
Deleted:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/build_utils.py
Deleted:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/build_utils_codes.py
Modified: gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.cc
===================================================================
--- gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++ gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -47,7 +47,7 @@
d_O=FSM.O();
d_NS=FSM.NS();
d_OS=FSM.OS();
- d_PS=FSM.PS();
+ d_PS=FSM.PS(); // is this going to make a deep copy?
d_PI=FSM.PI();
d_TMi=FSM.TMi();
d_TMl=FSM.TMl();
@@ -241,17 +241,21 @@
//######################################################################
void fsm::generate_PS_PI()
{
- d_PS.resize(d_I*d_S);
- d_PI.resize(d_I*d_S);
+ d_PS.resize(d_S);
+ d_PI.resize(d_S);
for(int i=0;i<d_S;i++) {
+ d_PS[i].resize(d_I*d_S); // max possible size
+ d_PI[i].resize(d_I*d_S);
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;
+ d_PS[i][j]=ii;
+ d_PI[i][j]=jj;
j++;
}
+ d_PS[i].resize(j);
+ d_PI[i].resize(j);
}
}
@@ -278,9 +282,11 @@
done = find_es(s);
attempts ++;
}
- if (done == false)
+ 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");
+ printf("state %d cannot be reached from all other states\n",s);
+ }
}
}
Modified: gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.h
===================================================================
--- gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.h
2007-02-05 07:15:51 UTC (rev 4378)
+++ gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.h
2007-02-05 14:46:05 UTC (rev 4379)
@@ -35,8 +35,8 @@
int d_O;
std::vector<int> d_NS;
std::vector<int> d_OS;
- std::vector<int> d_PS;
- std::vector<int> d_PI;
+ std::vector< std::vector<int> > d_PS;
+ std::vector< std::vector<int> > d_PI;
std::vector<int> d_TMi;
std::vector<int> d_TMl;
void generate_PS_PI ();
@@ -54,8 +54,8 @@
int O () const { return d_O; }
const std::vector<int> & NS () const { return d_NS; }
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< std::vector<int> > & PS () const { return d_PS; }
+ const std::vector< 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; }
};
Modified: gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.i
===================================================================
--- gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.i
2007-02-05 07:15:51 UTC (rev 4378)
+++ gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/fsm.i
2007-02-05 14:46:05 UTC (rev 4379)
@@ -27,8 +27,8 @@
int d_O;
std::vector<int> d_NS;
std::vector<int> d_OS;
- std::vector<int> d_PS;
- std::vector<int> d_PI;
+ std::vector< std::vector<int> > d_PS;
+ std::vector< std::vector<int> > d_PI;
std::vector<int> d_TMi;
std::vector<int> d_TMl;
void generate_PS_PI ();
@@ -45,8 +45,8 @@
int O () const { return d_O; }
const std::vector<int> & NS () const { return d_NS; }
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< std::vector<int> > & PS () const { return d_PS; }
+ const std::vector< 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; }
};
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_combined_f.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_combined_f.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_combined_f.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -138,8 +138,8 @@
void siso_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 std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
bool POSTI, bool POSTO,
@@ -171,9 +171,9 @@
norm=INF;
for(int j=0;j<S;j++) {
minm=INF;
- for(int i=0;i<I;i++) {
+ for(int i=0;i<PS[j].size();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]]];
+
mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]];
minm=(*p2mymin)(minm,mm);
}
alpha[(k+1)*S+j]=minm;
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_f.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_f.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_siso_f.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -129,8 +129,8 @@
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,
+ const std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
bool POSTI, bool POSTO,
@@ -157,9 +157,9 @@
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]]];
+ for(int i=0;i<PS[j].size();i++) {
+ //int i0 = j*I+i;
+
mm=alpha[k*S+PS[j][i]]+priori[k*I+PI[j][i]]+prioro[k*O+OS[PS[j][i]*I+PI[j][i]]];
minm=(*p2mymin)(minm,mm);
}
alpha[(k+1)*S+j]=minm;
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_X.cc.t
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_X.cc.t
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_X.cc.t
2007-02-05 14:46:05 UTC (rev 4379)
@@ -77,8 +77,8 @@
void viterbi_algorithm(int I, int S, int O,
const std::vector<int> &NS,
const std::vector<int> &OS,
- const std::vector<int> &PS,
- const std::vector<int> &PI,
+ const std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
const float *in, @TYPE@ *out)//,
@@ -106,9 +106,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
- int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+in[k*O+OS[PS[i0]*I+PI[i0]]])<minm)
+ for(int i=0;i<PS[j].size();i++) {
+ //int i0 = j*I+i;
+
if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -132,9 +132,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (@TYPE@) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (@TYPE@) PI[st][i0];
+ st=PS[st][i0];
}
}
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_b.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_b.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_b.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -77,8 +77,8 @@
void viterbi_algorithm(int I, int S, int O,
const std::vector<int> &NS,
const std::vector<int> &OS,
- const std::vector<int> &PS,
- const std::vector<int> &PI,
+ const std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
const float *in, unsigned char *out)//,
@@ -106,9 +106,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
- int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+in[k*O+OS[PS[i0]*I+PI[i0]]])<minm)
+ for(int i=0;i<PS[j].size();i++) {
+ //int i0 = j*I+i;
+
if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -132,9 +132,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (unsigned char) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (unsigned char) PI[st][i0];
+ st=PS[st][i0];
}
}
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_X.cc.t
2007-02-05 14:46:05 UTC (rev 4379)
@@ -86,8 +86,8 @@
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 std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
int D,
@@ -119,9 +119,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
+ for(int i=0;i<PS[j].size();i++) {
int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+metric[OS[PS[i0]*I+PI[i0]]])<minm)
+
if((mm=alpha[alphai*S+PS[j][i]]+metric[OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -145,9 +145,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (@TYPE@) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (@TYPE@) PI[st][i0];
+ st=PS[st][i0];
}
delete [] metric;
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_b.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_b.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_b.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -86,8 +86,8 @@
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 std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
int D,
@@ -119,9 +119,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
+ for(int i=0;i<PS[j].size();i++) {
int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+metric[OS[PS[i0]*I+PI[i0]]])<minm)
+
if((mm=alpha[alphai*S+PS[j][i]]+metric[OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -145,9 +145,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (unsigned char) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (unsigned char) PI[st][i0];
+ st=PS[st][i0];
}
delete [] metric;
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_i.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_i.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_i.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -86,8 +86,8 @@
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 std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
int D,
@@ -119,9 +119,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
+ for(int i=0;i<PS[j].size();i++) {
int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+metric[OS[PS[i0]*I+PI[i0]]])<minm)
+
if((mm=alpha[alphai*S+PS[j][i]]+metric[OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -145,9 +145,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (int) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (int) PI[st][i0];
+ st=PS[st][i0];
}
delete [] metric;
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_s.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_s.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_combined_s.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -86,8 +86,8 @@
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 std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
int D,
@@ -119,9 +119,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
+ for(int i=0;i<PS[j].size();i++) {
int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+metric[OS[PS[i0]*I+PI[i0]]])<minm)
+
if((mm=alpha[alphai*S+PS[j][i]]+metric[OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -145,9 +145,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (short) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (short) PI[st][i0];
+ st=PS[st][i0];
}
delete [] metric;
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_i.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_i.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_i.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -77,8 +77,8 @@
void viterbi_algorithm(int I, int S, int O,
const std::vector<int> &NS,
const std::vector<int> &OS,
- const std::vector<int> &PS,
- const std::vector<int> &PI,
+ const std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
const float *in, int *out)//,
@@ -106,9 +106,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
- int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+in[k*O+OS[PS[i0]*I+PI[i0]]])<minm)
+ for(int i=0;i<PS[j].size();i++) {
+ //int i0 = j*I+i;
+
if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -132,9 +132,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (int) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (int) PI[st][i0];
+ st=PS[st][i0];
}
}
Modified:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_s.cc
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_s.cc
2007-02-05 07:15:51 UTC (rev 4378)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/lib/trellis_viterbi_s.cc
2007-02-05 14:46:05 UTC (rev 4379)
@@ -77,8 +77,8 @@
void viterbi_algorithm(int I, int S, int O,
const std::vector<int> &NS,
const std::vector<int> &OS,
- const std::vector<int> &PS,
- const std::vector<int> &PI,
+ const std::vector< std::vector<int> > &PS,
+ const std::vector< std::vector<int> > &PI,
int K,
int S0,int SK,
const float *in, short *out)//,
@@ -106,9 +106,9 @@
for(int j=0;j<S;j++) { // for each next state do ACS
minm=INF;
minmi=0;
- for(int i=0;i<I;i++) {
- int i0 = j*I+i;
- if((mm=alpha[alphai*S+PS[i0]]+in[k*O+OS[PS[i0]*I+PI[i0]]])<minm)
+ for(int i=0;i<PS[j].size();i++) {
+ //int i0 = j*I+i;
+
if((mm=alpha[alphai*S+PS[j][i]]+in[k*O+OS[PS[j][i]*I+PI[j][i]]])<minm)
minm=mm,minmi=i;
}
trace[k*S+j]=minmi;
@@ -132,9 +132,9 @@
}
for(int k=K-1;k>=0;k--) { // traceback
- int i0=st*I+trace[k*S+st];
- out[k]= (short) PI[i0];
- st=PS[i0];
+ int i0=trace[k*S+st];
+ out[k]= (short) PI[st][i0];
+ st=PS[st][i0];
}
}
Added:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils.py
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils.py
(rev 0)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils.py
2007-02-05 14:46:05 UTC (rev 4379)
@@ -0,0 +1,193 @@
+#
+# 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., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+"""Misc utilities used at build time
+"""
+
+import re, os, os.path
+from build_utils_codes import *
+
+
+# set srcdir to the directory that contains Makefile.am
+try:
+ srcdir = os.environ['srcdir']
+except KeyError, e:
+ srcdir = "."
+srcdir = srcdir + '/'
+
+
+name_dict = {}
+
+def log_output_name (name):
+ (base, ext) = os.path.splitext (name)
+ ext = ext[1:] # drop the leading '.'
+
+ entry = name_dict.setdefault (ext, [])
+ entry.append (name)
+
+def open_and_log_name (name, dir):
+ f = open (name, dir)
+ log_output_name (name)
+ return f
+
+def expand_template (d, template_filename, extra = ""):
+ '''Given a dictionary D and a TEMPLATE_FILENAME, expand template into
output file
+ '''
+ output_extension = extract_extension (template_filename)
+ template = open_src (template_filename, 'r')
+ output_name = d['NAME'] + extra + '.' + output_extension
+ log_output_name (output_name)
+ output = open (output_name, 'w')
+ do_substitution (d, template, output)
+ template.close ()
+ output.close ()
+
+def output_glue (dirname):
+ output_makefile_fragment ()
+ output_ifile_include (dirname)
+
+def output_makefile_fragment ():
+ f = open ('Makefile.gen', 'w')
+ f.write ('#\n# This file is machine generated. All edits will be
overwritten\n#\n')
+ output_subfrag (f, 'h')
+ output_subfrag (f, 'i')
+ output_subfrag (f, 'cc')
+ f.close ()
+
+def output_ifile_include (dirname):
+ f = open ('%s_generated.i' % (dirname,), 'w')
+ f.write ('//\n// This file is machine generated. All edits will be
overwritten\n//\n')
+ files = name_dict.setdefault ('i', [])
+ files.sort ()
+ f.write ('%{\n')
+ for file in files:
+ f.write ('#include <%s>\n' % (file[0:-1] + 'h',))
+ f.write ('%}\n\n')
+ for file in files:
+ f.write ('%%include <%s>\n' % (file,))
+
+def output_subfrag (f, ext):
+ files = name_dict.setdefault (ext, [])
+ files.sort ()
+ f.write ("GENERATED_%s =" % (ext.upper ()))
+ for file in files:
+ f.write (" \\\n\t%s" % (file,))
+ f.write ("\n\n")
+
+
+def extract_extension (template_name):
+ # template name is something like: GrFIRfilterXXX.h.t
+ # we return everything between the penultimate . and .t
+ mo = re.search (r'\.([a-z]+)\.t$', template_name)
+ if not mo:
+ raise ValueError, "Incorrectly formed template_name '%s'" %
(template_name,)
+ return mo.group (1)
+
+def open_src (name, mode):
+ global srcdir
+ return open (os.path.join (srcdir, name), mode)
+
+def do_substitution (d, in_file, out_file):
+ def repl (match_obj):
+ key = match_obj.group (1)
+ # print key
+ return d[key]
+
+ inp = in_file.read ()
+ out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, inp)
+ out_file.write (out)
+
+
+
+copyright = '''/* -*- c++ -*- */
+/*
+ * Copyright 2003,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., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+'''
+
+def is_byte (code3):
+ if i_code (code3) == 'b' or o_code (code3) == 'b':
+ return '1'
+ else:
+ return '0'
+
+def is_short (code3):
+ if i_code (code3) == 's' or o_code (code3) == 's':
+ return '1'
+ else:
+ return '0'
+
+def is_int (code3):
+ if i_code (code3) == 'i' or o_code (code3) == 'i':
+ return '1'
+ else:
+ return '0'
+
+def is_float (code3):
+ if i_code (code3) == 'f' or o_code (code3) == 'f':
+ return '1'
+ else:
+ return '0'
+
+def is_complex (code3):
+ if i_code (code3) == 'c' or o_code (code3) == 'c':
+ return '1'
+ else:
+ return '0'
+
+
+
+
+def standard_dict (name, code3):
+ d = {}
+ d['NAME'] = name
+ d['GUARD_NAME'] = 'INCLUDED_%s_H' % name.upper ()
+ d['BASE_NAME'] = re.sub ('^trellis_', '', name)
+ d['SPTR_NAME'] = '%s_sptr' % name
+ d['WARNING'] = 'WARNING: this file is machine generated. Edits will be
over written'
+ d['COPYRIGHT'] = copyright
+ d['TYPE'] = i_type (code3)
+ d['I_TYPE'] = i_type (code3)
+ d['O_TYPE'] = o_type (code3)
+ d['TAP_TYPE'] = tap_type (code3)
+ d['IS_BYTE'] = is_byte (code3)
+ d['IS_SHORT'] = is_short (code3)
+ d['IS_INT'] = is_int (code3)
+ d['IS_FLOAT'] = is_float (code3)
+ d['IS_COMPLEX'] = is_complex (code3)
+ return d
Added:
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils_codes.py
===================================================================
---
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils_codes.py
(rev 0)
+++
gnuradio/branches/developers/michaelld/t29/gr-trellis/src/python/build_utils_codes.py
2007-02-05 14:46:05 UTC (rev 4379)
@@ -0,0 +1,193 @@
+#
+# 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., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+"""Misc utilities used at build time
+"""
+
+import re, os, os.path
+from build_utils_codes import *
+
+
+# set srcdir to the directory that contains Makefile.am
+try:
+ srcdir = os.environ['srcdir']
+except KeyError, e:
+ srcdir = "."
+srcdir = srcdir + '/'
+
+
+name_dict = {}
+
+def log_output_name (name):
+ (base, ext) = os.path.splitext (name)
+ ext = ext[1:] # drop the leading '.'
+
+ entry = name_dict.setdefault (ext, [])
+ entry.append (name)
+
+def open_and_log_name (name, dir):
+ f = open (name, dir)
+ log_output_name (name)
+ return f
+
+def expand_template (d, template_filename, extra = ""):
+ '''Given a dictionary D and a TEMPLATE_FILENAME, expand template into
output file
+ '''
+ output_extension = extract_extension (template_filename)
+ template = open_src (template_filename, 'r')
+ output_name = d['NAME'] + extra + '.' + output_extension
+ log_output_name (output_name)
+ output = open (output_name, 'w')
+ do_substitution (d, template, output)
+ template.close ()
+ output.close ()
+
+def output_glue (dirname):
+ output_makefile_fragment ()
+ output_ifile_include (dirname)
+
+def output_makefile_fragment ():
+ f = open ('Makefile.gen', 'w')
+ f.write ('#\n# This file is machine generated. All edits will be
overwritten\n#\n')
+ output_subfrag (f, 'h')
+ output_subfrag (f, 'i')
+ output_subfrag (f, 'cc')
+ f.close ()
+
+def output_ifile_include (dirname):
+ f = open ('%s_generated.i' % (dirname,), 'w')
+ f.write ('//\n// This file is machine generated. All edits will be
overwritten\n//\n')
+ files = name_dict.setdefault ('i', [])
+ files.sort ()
+ f.write ('%{\n')
+ for file in files:
+ f.write ('#include <%s>\n' % (file[0:-1] + 'h',))
+ f.write ('%}\n\n')
+ for file in files:
+ f.write ('%%include <%s>\n' % (file,))
+
+def output_subfrag (f, ext):
+ files = name_dict.setdefault (ext, [])
+ files.sort ()
+ f.write ("GENERATED_%s =" % (ext.upper ()))
+ for file in files:
+ f.write (" \\\n\t%s" % (file,))
+ f.write ("\n\n")
+
+
+def extract_extension (template_name):
+ # template name is something like: GrFIRfilterXXX.h.t
+ # we return everything between the penultimate . and .t
+ mo = re.search (r'\.([a-z]+)\.t$', template_name)
+ if not mo:
+ raise ValueError, "Incorrectly formed template_name '%s'" %
(template_name,)
+ return mo.group (1)
+
+def open_src (name, mode):
+ global srcdir
+ return open (os.path.join (srcdir, name), mode)
+
+def do_substitution (d, in_file, out_file):
+ def repl (match_obj):
+ key = match_obj.group (1)
+ # print key
+ return d[key]
+
+ inp = in_file.read ()
+ out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, inp)
+ out_file.write (out)
+
+
+
+copyright = '''/* -*- c++ -*- */
+/*
+ * Copyright 2003,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., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+'''
+
+def is_byte (code3):
+ if i_code (code3) == 'b' or o_code (code3) == 'b':
+ return '1'
+ else:
+ return '0'
+
+def is_short (code3):
+ if i_code (code3) == 's' or o_code (code3) == 's':
+ return '1'
+ else:
+ return '0'
+
+def is_int (code3):
+ if i_code (code3) == 'i' or o_code (code3) == 'i':
+ return '1'
+ else:
+ return '0'
+
+def is_float (code3):
+ if i_code (code3) == 'f' or o_code (code3) == 'f':
+ return '1'
+ else:
+ return '0'
+
+def is_complex (code3):
+ if i_code (code3) == 'c' or o_code (code3) == 'c':
+ return '1'
+ else:
+ return '0'
+
+
+
+
+def standard_dict (name, code3):
+ d = {}
+ d['NAME'] = name
+ d['GUARD_NAME'] = 'INCLUDED_%s_H' % name.upper ()
+ d['BASE_NAME'] = re.sub ('^trellis_', '', name)
+ d['SPTR_NAME'] = '%s_sptr' % name
+ d['WARNING'] = 'WARNING: this file is machine generated. Edits will be
over written'
+ d['COPYRIGHT'] = copyright
+ d['TYPE'] = i_type (code3)
+ d['I_TYPE'] = i_type (code3)
+ d['O_TYPE'] = o_type (code3)
+ d['TAP_TYPE'] = tap_type (code3)
+ d['IS_BYTE'] = is_byte (code3)
+ d['IS_SHORT'] = is_short (code3)
+ d['IS_INT'] = is_int (code3)
+ d['IS_FLOAT'] = is_float (code3)
+ d['IS_COMPLEX'] = is_complex (code3)
+ return d
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4379 - in gnuradio/branches/developers/michaelld/t29: gnuradio-examples/python/channel-coding/fsm_files gr-trellis/src/lib gr-trellis/src/python,
michaelld <=