Add interpolation method for discrete events
Some checks are pending
CI / testing (macos-latest) (push) Waiting to run
CI / testing (ubuntu-latest) (push) Waiting to run
CI / testing (windows-latest) (push) Waiting to run
CI / linting (macos-latest) (push) Waiting to run
CI / linting (ubuntu-latest) (push) Waiting to run
CI / linting (windows-latest) (push) Waiting to run
CI / Documentation (push) Waiting to run
CI / coverage (ubuntu-latest) (push) Waiting to run

This commit is contained in:
Joeri Exelmans 2025-11-04 10:49:56 +01:00
parent 654a0521f7
commit b6f705eb01

View file

@ -28,6 +28,28 @@ impl<T: Clone> InterpolationMethod<T> for Constant {
} }
} }
/// Fixed Value interpolation.
///
/// If the signal does not have a value at a given point, a fixed value is returned
pub struct DefaultFalse;
impl InterpolationMethod<Bool> for DefaultFalse {
fn at(a: &Sample<Bool>, b: &Sample<Bool>, time: Duration) -> Option<Bool> {
if time == b.time {
Some(b.value.clone())
} else if a.time <= time && time < b.time {
Some(a.value.clone())
} else {
Some(false)
}
}
fn find_intersection(_a: &Neighborhood<Bool>, _b: &Neighborhood<Bool>) -> Option<Sample<Bool>> {
// The signals must be either constant or colinear. Thus, return None.
None
}
}
/// Nearest interpolation. /// Nearest interpolation.
/// ///
/// Here, the signal value from the nearest sample (time-wise) is propagated to the /// Here, the signal value from the nearest sample (time-wise) is propagated to the