summaryrefslogtreecommitdiff
path: root/gr-trellis
diff options
context:
space:
mode:
Diffstat (limited to 'gr-trellis')
-rw-r--r--gr-trellis/src/lib/interleaver.cc29
-rw-r--r--gr-trellis/src/lib/interleaver.h1
-rw-r--r--gr-trellis/src/lib/interleaver.i1
3 files changed, 31 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();
+}
diff --git a/gr-trellis/src/lib/interleaver.h b/gr-trellis/src/lib/interleaver.h
index 466b0cdd2..5282a4ba8 100644
--- a/gr-trellis/src/lib/interleaver.h
+++ b/gr-trellis/src/lib/interleaver.h
@@ -42,6 +42,7 @@ public:
int K () const { return d_K; }
const std::vector<int> & INTER () const { return d_INTER; }
const std::vector<int> & DEINTER () const { return d_DEINTER; }
+ void write_interleaver_txt(std::string filename);
};
#endif
diff --git a/gr-trellis/src/lib/interleaver.i b/gr-trellis/src/lib/interleaver.i
index a5e68dc58..30a97bf6b 100644
--- a/gr-trellis/src/lib/interleaver.i
+++ b/gr-trellis/src/lib/interleaver.i
@@ -34,4 +34,5 @@ public:
int K () const { return d_K; }
const std::vector<int> & INTER () const { return d_INTER; }
const std::vector<int> & DEINTER () const { return d_DEINTER; }
+ void write_interleaver_txt(std::string filename);
};