Trait basic_dsp::InterpolationOps
source · pub trait InterpolationOps<S, T>where
S: ToSliceMut<T>,
T: RealNumber,{
// Required methods
fn interpolatef<B>(
&mut self,
buffer: &mut B,
function: &dyn RealImpulseResponse<T>,
interpolation_factor: T,
delay: T,
conv_len: usize
)
where B: for<'a> Buffer<'a, S, T>;
fn interpolatei<B>(
&mut self,
buffer: &mut B,
function: &dyn RealFrequencyResponse<T>,
interpolation_factor: u32
) -> Result<(), ErrorReason>
where B: for<'a> Buffer<'a, S, T>;
fn interpolate<B>(
&mut self,
buffer: &mut B,
function: Option<&dyn RealFrequencyResponse<T>>,
target_points: usize,
delay: T
) -> Result<(), ErrorReason>
where B: for<'a> Buffer<'a, S, T>;
fn interpft<B>(&mut self, buffer: &mut B, target_points: usize)
where B: for<'a> Buffer<'a, S, T>;
fn decimatei(&mut self, decimation_factor: u32, delay: u32);
}
Expand description
Provides interpolation operations for real and complex data vectors.
Required Methods§
sourcefn interpolatef<B>(
&mut self,
buffer: &mut B,
function: &dyn RealImpulseResponse<T>,
interpolation_factor: T,
delay: T,
conv_len: usize
)where
B: for<'a> Buffer<'a, S, T>,
fn interpolatef<B>(
&mut self,
buffer: &mut B,
function: &dyn RealImpulseResponse<T>,
interpolation_factor: T,
delay: T,
conv_len: usize
)where
B: for<'a> Buffer<'a, S, T>,
Interpolates self
with the convolution function function
by the real value
interpolation_factor
. InterpolationOps is done in time domain and the argument
conv_len
can be used to balance accuracy and computational performance.
A delay
can be used to delay or phase shift the vector.
The delay
considers self.delta()
.
The complexity of this interpolatef
is O(self.points() * conv_len)
,
while for interpolatei
it’s O(self.points() * log(self.points()))
. If computational
performance is important you should therefore decide how large conv_len
needs to be
to yield the desired accuracy. If you compare conv_len
to log(self.points)
you should
get a feeling for the expected performance difference. More important is however to do a
test run to compare the speed of interpolatef
and interpolatei
.
Together with the information that changing the vectors size change log(self.points()
but not conv_len
gives the indication that interpolatef
performs faster for larger
vectors while interpolatei
performs faster for smaller vectors.
sourcefn interpolatei<B>(
&mut self,
buffer: &mut B,
function: &dyn RealFrequencyResponse<T>,
interpolation_factor: u32
) -> Result<(), ErrorReason>where
B: for<'a> Buffer<'a, S, T>,
fn interpolatei<B>(
&mut self,
buffer: &mut B,
function: &dyn RealFrequencyResponse<T>,
interpolation_factor: u32
) -> Result<(), ErrorReason>where
B: for<'a> Buffer<'a, S, T>,
Interpolates self
with the convolution function function
by the integer value
interpolation_factor
. InterpolationOps is done in in frequency domain.
See the description of interpolatef
for some basic performance considerations.
§Failures
TransRes may report the following ErrorReason
members:
ArgumentFunctionMustBeSymmetric
: if!self.is_complex() && !function.is_symmetric()
or in words ifself
is a real vector andfunction
is asymmetric. Converting the vector into a complex vector before the interpolation is one way to resolve this error.
sourcefn interpolate<B>(
&mut self,
buffer: &mut B,
function: Option<&dyn RealFrequencyResponse<T>>,
target_points: usize,
delay: T
) -> Result<(), ErrorReason>where
B: for<'a> Buffer<'a, S, T>,
fn interpolate<B>(
&mut self,
buffer: &mut B,
function: Option<&dyn RealFrequencyResponse<T>>,
target_points: usize,
delay: T
) -> Result<(), ErrorReason>where
B: for<'a> Buffer<'a, S, T>,
Interpolates the signal in frequency domain by padding it with zeros.
sourcefn interpft<B>(&mut self, buffer: &mut B, target_points: usize)where
B: for<'a> Buffer<'a, S, T>,
fn interpft<B>(&mut self, buffer: &mut B, target_points: usize)where
B: for<'a> Buffer<'a, S, T>,
Interpolates the signal in frequency domain by padding it with zeros. This function preserves the shape of the signal in frequency domain.
Calling this function is the same as calling interpolate
with None
as
function and 0.0
as delay.