summaryrefslogtreecommitdiff
path: root/gr-trellis/src/lib/interleaver.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-trellis/src/lib/interleaver.cc')
-rw-r--r--gr-trellis/src/lib/interleaver.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/gr-trellis/src/lib/interleaver.cc b/gr-trellis/src/lib/interleaver.cc
index 93c194709..ad33d78bf 100644
--- a/gr-trellis/src/lib/interleaver.cc
+++ b/gr-trellis/src/lib/interleaver.cc
@@ -23,11 +23,16 @@
#include <cstdlib>
#include <cstdio>
#include <iostream>
+#include <string>
+#include <fstream>
#include <stdexcept>
#include <cmath>
#include "quicksort_index.h"
#include "interleaver.h"
+
+
+
interleaver::interleaver()
{
d_K=0;
@@ -104,3 +109,27 @@ interleaver::interleaver(int K, int seed)
d_DEINTER[d_INTER[i]]=i;
}
}
+
+
+
+
+
+//######################################################################
+//# Write an INTERLEAVER specification from a file.
+//# Format
+//# K
+//# blank line
+//# list of space separated K integers from 0 to K-1 in appropriate order
+//# optional comments
+//######################################################################
+void interleaver::write_interleaver_txt(std::string filename)
+{
+ std::ofstream interleaver_fname (filename.c_str());
+ if (!interleaver_fname) {std::cout << "file not found " << std::endl ; exit(-1);}
+ interleaver_fname << d_K << std::endl;
+ interleaver_fname << std::endl;
+ for(int i=0;i<d_K;i++)
+ interleaver_fname << d_INTER[i] << ' ';
+ interleaver_fname << std::endl;
+ interleaver_fname.close();
+}