Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/sameold/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ log = "0.4"
nalgebra = "^0.33.2"
num-complex = "^0.4"
num-traits = "^0.2"
slice-ring-buffer = "^0.3"

[dev-dependencies]
assert_approx_eq = "1.1.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/sameold/src/receiver/dcblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ mod tests {
output_history.push_scalar(uut.filter(100.0f32 + clk));
clk = -1.0 * clk;
}
assert_approx_eq!(output_history.as_slice()[0], 1.0f32, 1.0e-2);
assert_approx_eq!(output_history.as_slice()[1], -1.0f32, 1.0e-2);
assert_approx_eq!(output_history.inner()[0], 1.0f32, 1.0e-2);
assert_approx_eq!(output_history.inner()[1], -1.0f32, 1.0e-2);
}
}
5 changes: 2 additions & 3 deletions crates/sameold/src/receiver/demod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ impl FskDemod {
// * `< 0` for space
fn demod_now(&self) -> f32 {
// matched filter
let window = self.window_input.as_slice();
let mark = self.coeff_mark.filter(window);
let space = self.coeff_space.filter(window);
let mark = self.coeff_mark.filter(&self.window_input);
let space = self.coeff_space.filter(&self.window_input);

// non-coherently sum matched filter powers to obtain
// the symbol estimate
Expand Down
35 changes: 20 additions & 15 deletions crates/sameold/src/receiver/equalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ impl Equalizer {
let feedforward_wind = Window::new(nfeedforward);
let feedback_wind = Window::new(nfeedback);

assert_eq!(feedforward_coeff.inner().len(), feedforward_wind.len());
assert_eq!(feedback_coeff.inner().len(), feedback_wind.len());

Self {
relaxation,
regularization,
Expand Down Expand Up @@ -314,14 +317,16 @@ impl Equalizer {
self.relaxation,
self.regularization,
error,
self.feedforward_wind.as_ref(),
&self.feedforward_wind,
self.feedforward_coeff.as_mut(),
);

assert_eq!(self.feedback_wind.inner().len(), self.feedback_coeff.len());
nlms_update(
self.relaxation,
self.regularization,
-error,
self.feedback_wind.as_ref(),
&self.feedback_wind,
self.feedback_coeff.as_mut(),
);
}
Expand All @@ -346,17 +351,14 @@ enum EqualizerState {
// variable gain. The gain is computed based on the power
// of the input. The given `filter` taps are updated based
// on the input samples in `window`.
fn nlms_update(
relaxation: f32,
regularization: f32,
error: f32,
window: &[f32],
filter: &mut [f32],
) {
assert_eq!(window.len(), filter.len());

let gain = nlms_gain(relaxation, regularization, window);
for (coeff, data) in filter.iter_mut().zip(window.iter()) {
fn nlms_update<W>(relaxation: f32, regularization: f32, error: f32, window: W, filter: &mut [f32])
where
W: IntoIterator<Item = f32>,
W::IntoIter: DoubleEndedIterator + Clone,
{
let window = window.into_iter();
let gain = nlms_gain(relaxation, regularization, window.clone());
for (coeff, data) in filter.iter_mut().zip(window.rev()) {
*coeff += gain * error * data;
}
}
Expand All @@ -371,7 +373,10 @@ fn nlms_update(
//
// where `norm(x, 2)` is the L² norm of `x`
#[inline]
fn nlms_gain(relaxation: f32, regularization: f32, window: &[f32]) -> f32 {
fn nlms_gain<'a, W>(relaxation: f32, regularization: f32, window: W) -> f32
where
W: IntoIterator<Item = f32>,
{
let mut sumsq = 0.0f32;
for w in window {
sumsq += w * w;
Expand Down Expand Up @@ -473,7 +478,7 @@ mod tests {
RELAXATION,
REGULARIZATION,
err,
inverse_wind.as_ref(),
&inverse_wind,
inverse_coeff.as_mut(),
);
}
Expand Down
Loading
Loading