_trellis_la_SOURCES = \
trellis.cc \
fsm.cc \
+ quicksort_index.cc \
interleaver.cc \
trellis_calc_metric.cc \
trellis_permutation.cc \
# These headers get installed in ${prefix}/include/gnuradio
grinclude_HEADERS = \
fsm.h \
+ quicksort_index.h \
interleaver.h \
trellis_metric_type.h \
trellis_calc_metric.h \
* Boston, MA 02111-1307, USA.\r
*/\r
\r
+#include <cstdlib> \r
#include <cstdio>\r
#include <stdexcept>\r
#include <cmath>\r
+#include "quicksort_index.h"\r
#include "interleaver.h"\r
\r
interleaver::interleaver()\r
d_DEINTER[d_INTER[i]]=i;\r
}\r
}\r
+\r
+//######################################################################\r
+//# Generate a random interleaver\r
+//######################################################################\r
+interleaver::interleaver(const int K, unsigned int seed)\r
+{\r
+ d_K=K;\r
+ d_INTER.resize(d_K);\r
+ d_DEINTER.resize(d_K);\r
+\r
+ std::runtime_error ("Not yet implemented: something wrong with quicksort\n");\r
+/*\r
+ srand(seed); \r
+ std::vector<int> tmp(d_K);\r
+ for(int i=0;i<d_K;i++)\r
+ //d_INTER[i]=i;\r
+ tmp[i] = rand(); \r
+ quicksort_index <int> (tmp,d_INTER,0,d_K);\r
+\r
+ // generate DEINTER table\r
+ for(int i=0;i<d_K;i++) {\r
+ d_DEINTER[d_INTER[i]]=i;\r
+ }\r
+*/\r
+}\r
+\r
interleaver(const interleaver & INTERLEAVER);\r
interleaver(const int K, const std::vector<int> & INTER);\r
interleaver(const char *name);\r
+ interleaver(const int K, unsigned int seed);\r
int K () const { return d_K; }\r
const std::vector<int> & INTER () const { return d_INTER; }\r
const std::vector<int> & DEINTER () const { return d_DEINTER; }\r
interleaver(const interleaver & INTERLEAVER);\r
interleaver(const int K, const std::vector<int> & INTER);\r
interleaver(const char *name);\r
+ interleaver(const int K, unsigned int seed);\r
int K () const { return d_K; }\r
const std::vector<int> & INTER () const { return d_INTER; }\r
const std::vector<int> & DEINTER () const { return d_DEINTER; }\r
--- /dev/null
+/* -*- 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.
+ */
+
+#include "quicksort_index.h"
+
+template <class T> void SWAP (T & a, T & b)
+{
+T temp=a;
+a=b;
+b=temp;
+}
+
+template <class T> void quicksort_index(std::vector<T> & p, std::vector<int> & index, int left, int right)
+{
+T pivot;
+
+if (left < right) {
+ int i = left;
+ int j = right + 1;
+ pivot = p[left];
+ do {
+ do
+ i++;
+ while ((p[i] < pivot) && (i < right));
+ do
+ j--;
+ while ((p[j] > pivot) && (j > left));
+ if (i < j) {
+ SWAP <T> (p[i],p[j]);
+ SWAP <int> (index[i],index[j]);
+ }
+ } while (i < j);
+ SWAP <T> (p[left], p[j]);
+ SWAP <int> (index[left], index[j]);
+ quicksort_index(p,index, left, j-1);
+ quicksort_index(p,index, j+1, right);
+}
+}
--- /dev/null
+/* -*- 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_QUICKSORT_INDEX_H
+#define INCLUDED_QUICKSORT_INDEX_H
+
+#include <vector>
+
+template <class T> void SWAP (T & a, T & b);
+template <class T> void quicksort_index(std::vector<T> & p, std::vector<int> & index, int left, int right);
+
+#endif
%{
#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix
#include "fsm.h"
+#include "quicksort_index.h"
#include "interleaver.h"
#include "trellis_permutation.h"
#include <stdexcept>