3 * Copyright 2002 Free Software Foundation, Inc.
\r
5 * This file is part of GNU Radio
\r
7 * GNU Radio is free software; you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation; either version 2, or (at your option)
\r
10 * any later version.
\r
12 * GNU Radio is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with GNU Radio; see the file COPYING. If not, write to
\r
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
\r
20 * Boston, MA 02111-1307, USA.
\r
24 #include <stdexcept>
\r
26 #include "interleaver.h"
\r
28 interleaver::interleaver()
\r
32 d_DEINTER.resize(0);
\r
35 interleaver::interleaver(const interleaver &INTERLEAVER)
\r
37 d_K=INTERLEAVER.K();
\r
38 d_INTER=INTERLEAVER.INTER();
\r
39 d_DEINTER=INTERLEAVER.DEINTER();
\r
42 interleaver::interleaver(const int K, const std::vector<int> &INTER)
\r
46 d_DEINTER.resize(d_K);
\r
48 // generate DEINTER table
\r
49 for(int i=0;i<d_K;i++) {
\r
50 d_DEINTER[d_INTER[i]]=i;
\r
54 //######################################################################
\r
55 //# Read an INTERLEAVER specification from a file.
\r
56 //# Format (hopefully will become more flexible in the future...):
\r
59 //# list of space separated K integers from 0 to K-1 in appropriate order
\r
60 //# optional comments
\r
61 //######################################################################
\r
62 interleaver::interleaver(const char *name)
\r
64 FILE *interleaverfile;
\r
66 if((interleaverfile=fopen(name,"r"))==NULL)
\r
67 throw std::runtime_error ("file open error in interleaver()");
\r
68 //printf("file open error in interleaver()\n");
\r
70 fscanf(interleaverfile,"%d\n",&d_K);
\r
71 d_INTER.resize(d_K);
\r
72 d_DEINTER.resize(d_K);
\r
74 for(int i=0;i<d_K;i++) fscanf(interleaverfile,"%d",&(d_INTER[i]));
\r
76 // generate DEINTER table
\r
77 for(int i=0;i<d_K;i++) {
\r
78 d_DEINTER[d_INTER[i]]=i;
\r