Struct audio_processor_testing_helpers::charts::Linspace
source · pub struct Linspace<T, S, R>where
T: Ranged,
S: Clone,
R: LinspaceRoundingMethod<<T as Ranged>::ValueType>,
<T as Ranged>::ValueType: Add<S, Output = <T as Ranged>::ValueType> + PartialOrd + Clone,{ /* private fields */ }
Expand description
The coordinate combinator that transform a continous coordinate to a discrete coordinate to a discrete coordinate by a giving step.
For example, range 0f32..100f32
is a continuous coordinate, thus this prevent us having a
histogram on it since Plotters doesn’t know how to segment the range into buckets.
In this case, to get a histogram, we need to split the original range to a
set of discrete buckets (for example, 0.5 per bucket).
The linspace decorate abstracting this method. For example, we can have a discrete coordinate:
(0f32..100f32).step(0.5)
.
Linspace also supports different types of bucket matching method - This configuration alters the behavior of DiscreteCoord::index_of for Linspace coord spec
- Flooring, the value falls into the nearst bucket smaller than it. See Linspace::use_floor
- Round, the value falls into the nearst bucket. See Linearspace::use_round
- Ceiling, the value falls into the nearst bucket larger than itself. See Linspace::use_ceil
- Exact Matchting, the value must be exactly same as the butcket value. See Linspace::use_exact
Implementations§
source§impl<T, S, R> Linspace<T, S, R>
impl<T, S, R> Linspace<T, S, R>
sourcepub fn use_ceil(self) -> Linspace<T, S, Ceil<<T as Ranged>::ValueType>>
pub fn use_ceil(self) -> Linspace<T, S, Ceil<<T as Ranged>::ValueType>>
Set the linspace use the round up method for value matching
- returns: The newly created linspace that uses new matching method
sourcepub fn use_floor(self) -> Linspace<T, S, Floor<<T as Ranged>::ValueType>>
pub fn use_floor(self) -> Linspace<T, S, Floor<<T as Ranged>::ValueType>>
Set the linspace use the round down method for value matching
- returns: The newly created linspace that uses new matching method