[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3233 - gnuradio/trunk/gr-trellis/src/lib
From: |
anastas |
Subject: |
[Commit-gnuradio] r3233 - gnuradio/trunk/gr-trellis/src/lib |
Date: |
Fri, 11 Aug 2006 02:33:17 -0600 (MDT) |
Author: anastas
Date: 2006-08-11 02:33:17 -0600 (Fri, 11 Aug 2006)
New Revision: 3233
Added:
gnuradio/trunk/gr-trellis/src/lib/quicksort_index.cc
gnuradio/trunk/gr-trellis/src/lib/quicksort_index.h
Modified:
gnuradio/trunk/gr-trellis/src/lib/Makefile.am
gnuradio/trunk/gr-trellis/src/lib/interleaver.cc
gnuradio/trunk/gr-trellis/src/lib/interleaver.h
gnuradio/trunk/gr-trellis/src/lib/interleaver.i
gnuradio/trunk/gr-trellis/src/lib/trellis.i
Log:
Additional constructor for random interleaver (not working yet)
Modified: gnuradio/trunk/gr-trellis/src/lib/Makefile.am
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/Makefile.am 2006-08-11 07:03:03 UTC
(rev 3232)
+++ gnuradio/trunk/gr-trellis/src/lib/Makefile.am 2006-08-11 08:33:17 UTC
(rev 3233)
@@ -64,6 +64,7 @@
_trellis_la_SOURCES = \
trellis.cc \
fsm.cc \
+ quicksort_index.cc \
interleaver.cc \
trellis_calc_metric.cc \
trellis_permutation.cc \
@@ -85,6 +86,7 @@
# 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 \
Modified: gnuradio/trunk/gr-trellis/src/lib/interleaver.cc
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/interleaver.cc 2006-08-11 07:03:03 UTC
(rev 3232)
+++ gnuradio/trunk/gr-trellis/src/lib/interleaver.cc 2006-08-11 08:33:17 UTC
(rev 3233)
@@ -20,9 +20,11 @@
* Boston, MA 02111-1307, USA.
*/
+#include <cstdlib>
#include <cstdio>
#include <stdexcept>
#include <cmath>
+#include "quicksort_index.h"
#include "interleaver.h"
interleaver::interleaver()
@@ -78,3 +80,29 @@
d_DEINTER[d_INTER[i]]=i;
}
}
+
+//######################################################################
+//# Generate a random interleaver
+//######################################################################
+interleaver::interleaver(const int K, unsigned int seed)
+{
+ d_K=K;
+ d_INTER.resize(d_K);
+ d_DEINTER.resize(d_K);
+
+ std::runtime_error ("Not yet implemented: something wrong with quicksort\n");
+/*
+ srand(seed);
+ std::vector<int> tmp(d_K);
+ for(int i=0;i<d_K;i++)
+ //d_INTER[i]=i;
+ tmp[i] = rand();
+ quicksort_index <int> (tmp,d_INTER,0,d_K);
+
+ // generate DEINTER table
+ for(int i=0;i<d_K;i++) {
+ d_DEINTER[d_INTER[i]]=i;
+ }
+*/
+}
+
Modified: gnuradio/trunk/gr-trellis/src/lib/interleaver.h
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/interleaver.h 2006-08-11 07:03:03 UTC
(rev 3232)
+++ gnuradio/trunk/gr-trellis/src/lib/interleaver.h 2006-08-11 08:33:17 UTC
(rev 3233)
@@ -38,6 +38,7 @@
interleaver(const interleaver & INTERLEAVER);
interleaver(const int K, const std::vector<int> & INTER);
interleaver(const char *name);
+ interleaver(const int K, unsigned int seed);
int K () const { return d_K; }
const std::vector<int> & INTER () const { return d_INTER; }
const std::vector<int> & DEINTER () const { return d_DEINTER; }
Modified: gnuradio/trunk/gr-trellis/src/lib/interleaver.i
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/interleaver.i 2006-08-11 07:03:03 UTC
(rev 3232)
+++ gnuradio/trunk/gr-trellis/src/lib/interleaver.i 2006-08-11 08:33:17 UTC
(rev 3233)
@@ -30,6 +30,7 @@
interleaver(const interleaver & INTERLEAVER);
interleaver(const int K, const std::vector<int> & INTER);
interleaver(const char *name);
+ interleaver(const int K, unsigned int seed);
int K () const { return d_K; }
const std::vector<int> & INTER () const { return d_INTER; }
const std::vector<int> & DEINTER () const { return d_DEINTER; }
Added: gnuradio/trunk/gr-trellis/src/lib/quicksort_index.cc
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/quicksort_index.cc
(rev 0)
+++ gnuradio/trunk/gr-trellis/src/lib/quicksort_index.cc 2006-08-11
08:33:17 UTC (rev 3233)
@@ -0,0 +1,57 @@
+/* -*- 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);
+}
+}
Added: gnuradio/trunk/gr-trellis/src/lib/quicksort_index.h
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/quicksort_index.h
(rev 0)
+++ gnuradio/trunk/gr-trellis/src/lib/quicksort_index.h 2006-08-11 08:33:17 UTC
(rev 3233)
@@ -0,0 +1,31 @@
+/* -*- 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
Modified: gnuradio/trunk/gr-trellis/src/lib/trellis.i
===================================================================
--- gnuradio/trunk/gr-trellis/src/lib/trellis.i 2006-08-11 07:03:03 UTC (rev
3232)
+++ gnuradio/trunk/gr-trellis/src/lib/trellis.i 2006-08-11 08:33:17 UTC (rev
3233)
@@ -8,6 +8,7 @@
%{
#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>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3233 - gnuradio/trunk/gr-trellis/src/lib,
anastas <=