From 319caa5a3882142be42e03b0f20488730f5d208e Mon Sep 17 00:00:00 2001 From: eb Date: Sat, 19 Aug 2006 07:36:33 +0000 Subject: [PATCH] set svn:eol-style=native git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3355 221aa14e-8319-0410-a670-987f0aec2ac5 --- gr-trellis/src/lib/base.cc | 184 ++++----- gr-trellis/src/lib/base.h | 76 ++-- gr-trellis/src/lib/fsm.cc | 646 +++++++++++++++--------------- gr-trellis/src/lib/fsm.h | 126 +++--- gr-trellis/src/lib/interleaver.cc | 216 +++++----- gr-trellis/src/lib/interleaver.h | 94 ++--- 6 files changed, 671 insertions(+), 671 deletions(-) diff --git a/gr-trellis/src/lib/base.cc b/gr-trellis/src/lib/base.cc index 35ba2ea1..ca532ab0 100644 --- a/gr-trellis/src/lib/base.cc +++ b/gr-trellis/src/lib/base.cc @@ -1,92 +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 -#include -#include -#include "base.h" - - -bool dec2base(unsigned int num, int base, std::vector &s) -{ - int l = s.size(); - unsigned int n=num; - for(int i=0;i &s, int base) -{ - int l = s.size(); - unsigned int num=0; - for(int i=0;i &bases, std::vector &s) -{ - int l = s.size(); - unsigned int n=num; - for(int i=0;i &s, const std::vector &bases) -{ - int l = s.size(); - unsigned int num=0; - for(int i=0;i +#include +#include +#include "base.h" + + +bool dec2base(unsigned int num, int base, std::vector &s) +{ + int l = s.size(); + unsigned int n=num; + for(int i=0;i &s, int base) +{ + int l = s.size(); + unsigned int num=0; + for(int i=0;i &bases, std::vector &s) +{ + int l = s.size(); + unsigned int n=num; + for(int i=0;i &s, const std::vector &bases) +{ + int l = s.size(); + unsigned int num=0; + for(int i=0;i - -/*! - * \brief change base - */ - - -bool dec2base(unsigned int num, int base, std::vector &s); -bool dec2bases(unsigned int num, const std::vector &bases, std::vector &s); -unsigned int base2dec(const std::vector &s, int base); -unsigned int bases2dec(const std::vector &s, const std::vector &bases); - -#endif +/* -*- 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 + +/*! + * \brief change base + */ + + +bool dec2base(unsigned int num, int base, std::vector &s); +bool dec2bases(unsigned int num, const std::vector &bases, std::vector &s); +unsigned int base2dec(const std::vector &s, int base); +unsigned int bases2dec(const std::vector &s, const std::vector &bases); + +#endif diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index f3430883..2cf1a6d5 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -1,323 +1,323 @@ -/* -*- 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 -#include -#include -#include "base.h" -#include "fsm.h" - - -fsm::fsm() -{ - d_I=0; - d_S=0; - d_O=0; - d_NS.resize(0); - 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) -{ - d_I=FSM.I(); - d_S=FSM.S(); - d_O=FSM.O(); - d_NS=FSM.NS(); - d_OS=FSM.OS(); - d_PS=FSM.PS(); - d_PI=FSM.PI(); - d_TMi=FSM.TMi(); - d_TMl=FSM.TMl(); -} - -fsm::fsm(int I, int S, int O, const std::vector &NS, const std::vector &OS) -{ - d_I=I; - d_S=S; - d_O=O; - d_NS=NS; - d_OS=OS; - - generate_PS_PI(); - generate_TM(); -} - -//###################################################################### -//# Read an FSM specification from a file. -//# Format (hopefully will become more flexible in the future...): -//# I S O (in the first line) -//# blank line -//# Next state matrix (S lines, each with I integers separated by spaces) -//# blank line -//# output symbol matrix (S lines, each with I integers separated by spaces) -//# optional comments -//###################################################################### -fsm::fsm(const char *name) -{ - FILE *fsmfile; - - if((fsmfile=fopen(name,"r"))==NULL) - 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); - - for(int i=0;i &G) -{ - - // calculate maximum memory requirements for each input stream - std::vector max_mem_x(k,-1); - int max_mem = -1; - for(int i=0;imax_mem_x[i]) - max_mem_x[i]=mem; - if(mem>max_mem) - max_mem=mem; - } - } - -//printf("max_mem_x\n"); -//for(int j=0;j > Gb(k*n); - for(int j=0;j bases_x(k); - for(int j=0;j sx(k); - std::vector nsx(k); - std::vector tx(k); - std::vector > tb(k); - for(int j=0;j inb(k); - std::vector outb(n); - - - for(int s=0;s +#include +#include +#include "base.h" +#include "fsm.h" + + +fsm::fsm() +{ + d_I=0; + d_S=0; + d_O=0; + d_NS.resize(0); + 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) +{ + d_I=FSM.I(); + d_S=FSM.S(); + d_O=FSM.O(); + d_NS=FSM.NS(); + d_OS=FSM.OS(); + d_PS=FSM.PS(); + d_PI=FSM.PI(); + d_TMi=FSM.TMi(); + d_TMl=FSM.TMl(); +} + +fsm::fsm(int I, int S, int O, const std::vector &NS, const std::vector &OS) +{ + d_I=I; + d_S=S; + d_O=O; + d_NS=NS; + d_OS=OS; + + generate_PS_PI(); + generate_TM(); +} + +//###################################################################### +//# Read an FSM specification from a file. +//# Format (hopefully will become more flexible in the future...): +//# I S O (in the first line) +//# blank line +//# Next state matrix (S lines, each with I integers separated by spaces) +//# blank line +//# output symbol matrix (S lines, each with I integers separated by spaces) +//# optional comments +//###################################################################### +fsm::fsm(const char *name) +{ + FILE *fsmfile; + + if((fsmfile=fopen(name,"r"))==NULL) + 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); + + for(int i=0;i &G) +{ + + // calculate maximum memory requirements for each input stream + std::vector max_mem_x(k,-1); + int max_mem = -1; + for(int i=0;imax_mem_x[i]) + max_mem_x[i]=mem; + if(mem>max_mem) + max_mem=mem; + } + } + +//printf("max_mem_x\n"); +//for(int j=0;j > Gb(k*n); + for(int j=0;j bases_x(k); + for(int j=0;j sx(k); + std::vector nsx(k); + std::vector tx(k); + std::vector > tb(k); + for(int j=0;j inb(k); + std::vector outb(n); + + + for(int s=0;s - -/*! - * \brief FSM class - */ -class fsm { -private: - int d_I; - int d_S; - int d_O; - std::vector d_NS; - std::vector d_OS; - std::vector d_PS; - std::vector d_PI; - std::vector d_TMi; - std::vector d_TMl; - void generate_PS_PI (); - void generate_TM (); - bool find_es(int es); -public: - fsm(); - fsm(const fsm &FSM); - fsm(int I, int S, int O, const std::vector &NS, const std::vector &OS); - fsm(const char *name); - fsm(int k, int n, const std::vector &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; } - const std::vector & NS () const { return d_NS; } - const std::vector & OS () const { return d_OS; } - const std::vector & PS () const { return d_PS; } - const std::vector & PI () const { return d_PI; } - const std::vector & TMi () const { return d_TMi; } - const std::vector & TMl () const { return d_TMl; } -}; - -#endif +/* -*- 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_FSM_H +#define INCLUDED_TRELLIS_FSM_H + +#include + +/*! + * \brief FSM class + */ +class fsm { +private: + int d_I; + int d_S; + int d_O; + std::vector d_NS; + std::vector d_OS; + std::vector d_PS; + std::vector d_PI; + std::vector d_TMi; + std::vector d_TMl; + void generate_PS_PI (); + void generate_TM (); + bool find_es(int es); +public: + fsm(); + fsm(const fsm &FSM); + fsm(int I, int S, int O, const std::vector &NS, const std::vector &OS); + fsm(const char *name); + fsm(int k, int n, const std::vector &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; } + const std::vector & NS () const { return d_NS; } + const std::vector & OS () const { return d_OS; } + const std::vector & PS () const { return d_PS; } + const std::vector & PI () const { return d_PI; } + const std::vector & TMi () const { return d_TMi; } + const std::vector & TMl () const { return d_TMl; } +}; + +#endif diff --git a/gr-trellis/src/lib/interleaver.cc b/gr-trellis/src/lib/interleaver.cc index 174d31c0..b17fae54 100644 --- a/gr-trellis/src/lib/interleaver.cc +++ b/gr-trellis/src/lib/interleaver.cc @@ -1,108 +1,108 @@ -/* -*- 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 -#include -#include -#include -#include -#include "quicksort_index.h" -#include "interleaver.h" - -interleaver::interleaver() -{ - d_K=0; - d_INTER.resize(0); - d_DEINTER.resize(0); -} - -interleaver::interleaver(const interleaver &INTERLEAVER) -{ - d_K=INTERLEAVER.K(); - d_INTER=INTERLEAVER.INTER(); - d_DEINTER=INTERLEAVER.DEINTER(); -} - -interleaver::interleaver(int K, const std::vector &INTER) -{ - d_K=K; - d_INTER=INTER; - d_DEINTER.resize(d_K); - - // generate DEINTER table - for(int i=0;i tmp(d_K); - for(int i=0;i (tmp,d_INTER,0,d_K-1); got to resolve this... - quicksort_index1 (tmp,d_INTER,0,d_K-1); - - // generate DEINTER table - for(int i=0;i +#include +#include +#include +#include +#include "quicksort_index.h" +#include "interleaver.h" + +interleaver::interleaver() +{ + d_K=0; + d_INTER.resize(0); + d_DEINTER.resize(0); +} + +interleaver::interleaver(const interleaver &INTERLEAVER) +{ + d_K=INTERLEAVER.K(); + d_INTER=INTERLEAVER.INTER(); + d_DEINTER=INTERLEAVER.DEINTER(); +} + +interleaver::interleaver(int K, const std::vector &INTER) +{ + d_K=K; + d_INTER=INTER; + d_DEINTER.resize(d_K); + + // generate DEINTER table + for(int i=0;i tmp(d_K); + for(int i=0;i (tmp,d_INTER,0,d_K-1); got to resolve this... + quicksort_index1 (tmp,d_INTER,0,d_K-1); + + // generate DEINTER table + for(int i=0;i - -/*! - * \brief INTERLEAVER class - */ -class interleaver { -private: - int d_K; - std::vector d_INTER; - std::vector d_DEINTER; -public: - interleaver(); - interleaver(const interleaver & INTERLEAVER); - interleaver(int K, const std::vector & INTER); - interleaver(const char *name); - interleaver(int K, unsigned int seed); - int K () const { return d_K; } - const std::vector & INTER () const { return d_INTER; } - const std::vector & DEINTER () const { return d_DEINTER; } -}; - -#endif +/* -*- 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_INTERLEAVER_H +#define INCLUDED_TRELLIS_INTERLEAVER_H + +#include + +/*! + * \brief INTERLEAVER class + */ +class interleaver { +private: + int d_K; + std::vector d_INTER; + std::vector d_DEINTER; +public: + interleaver(); + interleaver(const interleaver & INTERLEAVER); + interleaver(int K, const std::vector & INTER); + interleaver(const char *name); + interleaver(int K, unsigned int seed); + int K () const { return d_K; } + const std::vector & INTER () const { return d_INTER; } + const std::vector & DEINTER () const { return d_DEINTER; } +}; + +#endif -- 2.30.2