[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7563 - gnuradio/branches/developers/gnychis/matched_f
From: |
gnychis |
Subject: |
[Commit-gnuradio] r7563 - gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter |
Date: |
Mon, 4 Feb 2008 23:43:10 -0700 (MST) |
Author: gnychis
Date: 2008-02-04 23:43:09 -0700 (Mon, 04 Feb 2008)
New Revision: 7563
Modified:
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.cc
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.h
Log:
first shot at matched filter code, currently untested
Modified:
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.cc
===================================================================
---
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.cc
2008-02-05 06:17:10 UTC (rev 7562)
+++
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.cc
2008-02-05 06:43:09 UTC (rev 7563)
@@ -25,6 +25,8 @@
#endif
#include <gr_matched_filter_ccc.h>
+#include <gr_fir_fff.h>
+#include <gr_fir_util.h>
#include <gr_io_signature.h>
#include <math.h>
#include <assert.h>
@@ -41,26 +43,52 @@
gr_matched_filter_ccc::gr_matched_filter_ccc (const std::vector<gr_complex>
&taps)
: gr_sync_block ("matched_filter_ccc",
- gr_make_io_signature (1, 1, sizeof(gr_complex)),
- gr_make_io_signature (1, 1, sizeof(gr_complex)))
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex))),
+ d_updated(false)
{
- actual_set_taps(taps);
+ split_complex((gr_complex *)&taps[0], taps.size(), d_new_real_taps,
d_new_imag_taps);
+ d_fir_real = gr_fir_util::create_gr_fir_fff(d_new_real_taps);
+ d_fir_imag = gr_fir_util::create_gr_fir_fff(d_new_imag_taps);
+ set_history(d_fir_real->ntaps());
}
gr_matched_filter_ccc::~gr_matched_filter_ccc()
{
+ delete d_fir_real;
+ delete d_fir_imag;
}
void
gr_matched_filter_ccc::set_taps (const std::vector<gr_complex> &taps)
{
+// split_complex(taps, d_new_real_taps, d_new_imag_taps);
+ d_updated = true;
+}
+// Split the complex vector in to two float vectors, one real and one imag
+void
+gr_matched_filter_ccc::split_complex(gr_complex *comp,
+ long nitems,
+ std::vector<float> &real,
+ std::vector<float> &imag)
+{
+ real.clear();
+ imag.clear();
+ for(int i=0; i < (int)nitems; i++) {
+ real.push_back(comp[i].real());
+ imag.push_back(comp[i].imag());
+ }
}
void
-gr_matched_filter_ccc::actual_set_taps (const std::vector<gr_complex> &taps)
+gr_matched_filter_ccc::make_complex(gr_complex *comp,
+ long nitems,
+ const std::vector<float> &real,
+ const std::vector<float> &imag)
{
-
+ for(int i=0; i < (int)nitems; i++)
+ comp[i] = gr_complex(real[i], imag[i]);
}
int
@@ -71,5 +99,26 @@
gr_complex *in = (gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
+ if(d_updated) {
+ d_fir_real->set_taps(d_new_real_taps);
+ d_fir_imag->set_taps(d_new_imag_taps);
+ set_history(d_fir_real->ntaps());
+ d_updated=false;
+ return 0;
+ }
+
+ // Split the incoming real and imag
+ std::vector<float> in_real, in_imag;
+ split_complex(in, noutput_items, in_real, in_imag);
+
+ // Perform the dot product on each component separately
+ std::vector<float> out_real(noutput_items);
+ std::vector<float> out_imag(noutput_items);
+ d_fir_real->filterN(&out_real[0], &in_real[0], noutput_items);
+ d_fir_imag->filterN(&out_imag[0], &out_imag[0], noutput_items);
+
+ // Recombine the real and imaginary
+ make_complex(out, noutput_items, out_real, out_imag);
+
return noutput_items;
}
Modified:
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.h
===================================================================
---
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.h
2008-02-05 06:17:10 UTC (rev 7562)
+++
gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter/gr_matched_filter_ccc.h
2008-02-05 06:43:09 UTC (rev 7563)
@@ -25,7 +25,9 @@
#include <gr_sync_block.h>
#include <gr_io_signature.h>
+#include <gr_fir_fff.h>
+
class gr_matched_filter_ccc;
typedef boost::shared_ptr<gr_matched_filter_ccc> gr_matched_filter_ccc_sptr;
@@ -43,13 +45,22 @@
private:
friend gr_matched_filter_ccc_sptr gr_make_matched_filter_ccc (const
std::vector<gr_complex> &taps);
+ gr_fir_fff *d_fir_real;
+ gr_fir_fff *d_fir_imag;
+ std::vector<float> d_new_real_taps;
+ std::vector<float> d_new_imag_taps;
+ bool d_updated;
+
gr_matched_filter_ccc(const std::vector<gr_complex> &taps);
+ void split_complex(gr_complex *comp,
+ long nitems,
+ std::vector<float> &real,
+ std::vector<float> &imag);
- int d_ntaps;
- int d_nsamples;
-
- void actual_set_taps(const std::vector<gr_complex> &taps);
-
+ void make_complex(gr_complex *comp,
+ long nitems,
+ const std::vector<float> &real,
+ const std::vector<float> &imag);
public:
~gr_matched_filter_ccc ();
@@ -60,4 +71,5 @@
gr_vector_void_star &output_items);
};
+
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7563 - gnuradio/branches/developers/gnychis/matched_filter/gnuradio-core/src/lib/filter,
gnychis <=