diff options
author | Achilleas Anastasopoulos | 2011-02-18 23:55:50 -0500 |
---|---|---|
committer | Achilleas Anastasopoulos | 2011-02-18 23:55:50 -0500 |
commit | f737dc447be394e509907acec90a6a4492e16995 (patch) | |
tree | fe73abfc8e8bc88eba09242d8edb8ac4ace50337 /gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t | |
parent | 4475307c9465514457dc16ad515508de560215eb (diff) | |
download | gnuradio-f737dc447be394e509907acec90a6a4492e16995.tar.gz gnuradio-f737dc447be394e509907acec90a6a4492e16995.tar.bz2 gnuradio-f737dc447be394e509907acec90a6a4492e16995.zip |
templated siso_combined
removed Makefile.gen from git tracking
Diffstat (limited to 'gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t')
-rw-r--r-- | gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t | 333 |
1 files changed, 3 insertions, 330 deletions
diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t index c23445e61..f354197dd 100644 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t +++ b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t @@ -30,6 +30,8 @@ #include <gr_io_signature.h> #include <assert.h> #include <iostream> +#include "core_algorithms.h" + static const float INF = 1.0e9; @@ -73,7 +75,7 @@ trellis_make_@BASE_NAME@ ( gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), d_FSMo (FSMo), d_STo0 (STo0), d_SToK (SToK), - d_FSMi (FSMo), d_STi0 (STi0), d_STiK (STiK), + d_FSMi (FSMi), d_STi0 (STi0), d_STiK (STiK), d_INTERLEAVER (INTERLEAVER), d_blocklength (blocklength), d_repetitions (repetitions), @@ -98,337 +100,8 @@ void } } -//======================================= - -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_outer_algorithm(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< 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, - @O_TYPE@ *data - ) -{ - float norm,mm,minm; - std::vector<float> alpha(S*(K+1)); - std::vector<float> beta(S*(K+1)); - - - 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(unsigned 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; - 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."); - -} - -//================================== - -void siso_inner_algorithm_combined(int I, int S, int O, - const std::vector<int> &NS, - const std::vector<int> &OS, - const std::vector< std::vector<int> > &PS, - const std::vector< std::vector<int> > &PI, - int K, - int S0,int SK, - bool POSTI, bool POSTO, - float (*p2mymin)(float,float), - int D, - const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE, - const float *priori, const @I_TYPE@ *observations, float *post - ) -{ - float norm,mm,minm; - std::vector<float> alpha(S*(K+1)); - std::vector<float> beta(S*(K+1)); - float *prioro = new float[O*K]; - - - 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 - calc_metric(O, D, TABLE, &(observations[k*D]), &(prioro[k*O]),TYPE); // calc metrics - norm=INF; - for(int j=0;j<S;j++) { - minm=INF; - for(unsigned 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; - 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."); - - delete [] prioro; - -} - - -//========================================================== - - -void sccc_decoder_combined( - const fsm &FSMo, int STo0, int SToK, - const fsm &FSMi, int STi0, int STiK, - const interleaver &INTERLEAVER, int blocklength, int repetitions, - float (*p2mymin)(float,float), - int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, - const @I_TYPE@ *observations, @O_TYPE@ *data - ) -{ - - - - -} - - //d_FSMo.I(),d_FSMo.S(),d_FSMo.O(),d_FSMo.NS(),d_FSMo.OS(),d_FSMo.PS(),d_FSMo.PI(), //=========================================================== int |