Further MatchedFilter optimization using algebraic identities and stuff.

Can't stop premature optimization!!!
This commit is contained in:
Jared Boone 2015-11-05 22:26:36 -08:00
parent 100761481e
commit ae225e8c3b

View File

@ -31,26 +31,26 @@ bool MatchedFilter::execute_once(
advance_decimation_phase(); advance_decimation_phase();
if( is_new_decimation_cycle() ) { if( is_new_decimation_cycle() ) {
float r_n = 0.0f; float sr_tr = 0.0f;
float i_n = 0.0f; float si_tr = 0.0f;
float r_p = 0.0f; float si_ti = 0.0f;
float i_p = 0.0f; float sr_ti = 0.0f;
for(size_t n=0; n<taps_count_; n++) { for(size_t n=0; n<taps_count_; n++) {
const auto sample = samples_[n]; const auto sample = samples_[n];
const auto tap = taps_reversed_[n]; const auto tap = taps_reversed_[n];
sr_tr += sample.real() * tap.real();
si_ti += sample.imag() * tap.imag();
si_tr += sample.imag() * tap.real();
sr_ti += sample.real() * tap.imag();
}
// N: complex multiple of samples and taps (conjugate, tap.i negated). // N: complex multiple of samples and taps (conjugate, tap.i negated).
// P: complex multiply of samples and taps. // P: complex multiply of samples and taps.
r_n += sample.real() * tap.real(); const auto r_n = sr_tr + si_ti;
i_n -= sample.real() * tap.imag(); const auto r_p = sr_tr - si_ti;
r_n += sample.imag() * tap.imag(); const auto i_n = si_tr - sr_ti;
i_n += sample.imag() * tap.real(); const auto i_p = si_tr + sr_ti;
r_p += sample.real() * tap.real();
i_p += sample.real() * tap.imag();
r_p -= sample.imag() * tap.imag();
i_p += sample.imag() * tap.real();
}
const auto mag_n = std::sqrt(r_n * r_n + i_n * i_n); const auto mag_n = std::sqrt(r_n * r_n + i_n * i_n);
const auto mag_p = std::sqrt(r_p * r_p + i_p * i_p); const auto mag_p = std::sqrt(r_p * r_p + i_p * i_p);