Struct basic_dsp::ComplexFreqVector
[−]
[src]
pub struct ComplexFreqVector<T> where T: RealNumber {
// some fields omitted
}
A 1xN (one times N elements) or Nx1 data vector as used for most digital signal processing (DSP) operations. All data vector operations consume the vector they operate on and return a new vector. A consumed vector must not be accessed again.
Vectors come in different flavors:
- Time or Frequency domain
- Real or Complex numbers
- 32bit or 64bit floating point numbers
The first two flavors define meta information about the vector and provide compile time information what
operations are available with the given vector and how this will transform the vector. This makes sure that
some invalid operations are already discovered at compile time. In case that this isn't desired or the information
about the vector isn't known at compile time there are the generic DataVector32
and DataVector64
vectors
available.
32bit and 64bit flavors trade performance and memory consumption against accuracy. 32bit vectors are roughly two times faster than 64bit vectors for most operations. But remember that you should benchmark first before you give away accuracy for performance unless however you are sure that 32bit accuracy is certainly good enough.
Methods
impl<T> ComplexFreqVector<T> where T: RealNumber
[src]
fn from_interleaved_no_copy_with_options(data: Vec<T>, options: MultiCoreSettings) -> Self
Same as from_interleaved_no_copy
but also allows to set multicore options.
fn from_interleaved_with_options(data: &[T], options: MultiCoreSettings) -> Self
Same as from_interleaved
but also allows to set multicore options.
fn from_interleaved_with_delta_and_options(data: &[T], delta: T, options: MultiCoreSettings) -> Self
Same as from_interleaved_with_delta
but also allows to set multicore options.
fn empty_with_options(options: MultiCoreSettings) -> Self
Same as complex_empty
but also allows to set multicore options.
fn empty_with_delta_and_options(delta: T, options: MultiCoreSettings) -> Self
Same as complex_empty_with_delta
but also allows to set multicore options.
fn from_constant_with_options(constant: Complex<T>, length: usize, options: MultiCoreSettings) -> Self
Same as complex_from_constant
but also allows to set multicore options.
fn from_constant_with_delta_and_options(constant: Complex<T>, length: usize, delta: T, options: MultiCoreSettings) -> Self
Same as complex_from_constant_with_delta
but also allows to set multicore options.
fn from_real_imag_with_options(real: &[T], imag: &[T], options: MultiCoreSettings) -> Self
Same as from_real_imag
but also allows to set multicore options.
fn from_real_imag_with_delta_and_options(real: &[T], imag: &[T], delta: T, options: MultiCoreSettings) -> Self
Same as from_real_imag_with_delta
but also allows to set multicore options.
fn from_mag_phase_with_options(magnitude: &[T], phase: &[T], options: MultiCoreSettings) -> Self
Same as from_mag_phase
but also allows to set multicore options.
fn from_mag_phase_with_delta_and_options(magnitude: &[T], phase: &[T], delta: T, options: MultiCoreSettings) -> Self
Same as from_mag_phase_with_delta
but also allows to set multicore options.
fn from_interleaved_no_copy(data: Vec<T>) -> Self
Creates a complex DataVector
by consuming a Vec
. Data is in interleaved format: i0, q0, i1, q1, ...
.
This operation is more memory efficient than the other options to create a vector, however if used outside of Rust then it holds the risk that the user will access the data parameter after the vector has been created causing all types of issues.
fn from_interleaved(data: &[T]) -> Self
Creates a complex DataVector
from an array or sequence. Data is in interleaved format: i0, q0, i1, q1, ...
. delta
is defaulted to 1
.
fn from_interleaved_with_delta(data: &[T], delta: T) -> Self
Creates a complex DataVector
from an array or sequence. Data is in interleaved format: i0, q0, i1, q1, ...
. delta
is set to the given value.
fn empty() -> Self
Creates a complex and empty DataVector
and sets delta
to 1.0 value.
fn empty_with_delta(delta: T) -> Self
Creates a complex and empty DataVector
and sets delta
to the given value.
fn from_constant(constant: Complex<T>, length: usize) -> Self
Creates a complex DataVector
with length
elements all set to the value of constant
. delta
is defaulted to 1
.
fn from_constant_with_delta(constant: Complex<T>, length: usize, delta: T) -> Self
Creates a complex DataVector
with length
elements all set to the value of constant
and sets delta
to the given value.
fn from_real_imag(real: &[T], imag: &[T]) -> Self
Creates a complex DataVector
from an array with real and an array imaginary data. delta
is set to 1.
Arrays must have the same length.
fn from_real_imag_with_delta(real: &[T], imag: &[T], delta: T) -> Self
Creates a complex DataVector
from an array with real and an array imaginary data. delta
is set to the given value.
Arrays must have the same length.
fn from_mag_phase(magnitude: &[T], phase: &[T]) -> Self
Creates a complex DataVector
from an array with magnitude and an array with phase data. delta
is set to 1.
Arrays must have the same length. Phase must be in [rad].
fn from_mag_phase_with_delta(magnitude: &[T], phase: &[T], delta: T) -> Self
Creates a complex DataVector
from an array with magnitude and an array with phase data. delta
is set to the given value.
Arrays must have the same length. Phase must be in [rad].
fn from_complex(complex: &[Complex<T>]) -> Self
Creates a complex DataVector
from an array of complex numbers. delta
is set to 1.
fn from_complex_with_delta(complex: &[Complex<T>], delta: T) -> Self
Creates a complex DataVector
from an array of complex numbers. delta
is set to the given value.
fn from_complex_with_delta_and_options(complex: &[Complex<T>], delta: T, options: MultiCoreSettings) -> Self
Creates a complex DataVector
from an array of complex numbers.
Trait Implementations
impl FrequencyDomainOperations<f32> for ComplexFreqVector<f32>
[src]
type ComplexTimePartner = ComplexTimeVector<f32>
fn plain_ifft(self) -> VecResult<ComplexTimeVector<f32>>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector. Read more
fn mirror(self) -> VecResult<ComplexFreqVector<f32>>
This function mirrors the spectrum vector to transform a symmetric spectrum into a full spectrum with the DC element at index 0 (no fft shift/swap halves). Read more
fn ifft(self) -> VecResult<Self::ComplexTimePartner>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector. # Example Read more
fn windowed_ifft(self, window: &WindowFunction<f32>) -> VecResult<Self::ComplexTimePartner>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector and removes the FFT window. Read more
fn fft_shift(self) -> VecResult<Self>
Swaps vector halves after a Fourier Transformation.
fn ifft_shift(self) -> VecResult<Self>
Swaps vector halves before an Inverse Fourier Transformation.
impl SymmetricFrequencyDomainOperations<f32> for ComplexFreqVector<f32>
[src]
type RealTimePartner = RealTimeVector<f32>
fn plain_sifft(self) -> VecResult<Self::RealTimePartner>
Performs a Symmetric Inverse Fast Fourier Transformation under the assumption that self
contains half of a symmetric spectrum starting from 0 Hz. This assumption isn't verified and no error is raised if the spectrum isn't symmetric. The reason for this is that there is no robust verification possible. Read more
fn sifft(self) -> VecResult<Self::RealTimePartner>
Performs a Symmetric Inverse Fast Fourier Transformation under the assumption that self
contains half of a symmetric spectrum starting from 0 Hz. This assumption isn't verified and no error is raised if the spectrum isn't symmetric. The reason for this is that there is no robust verification possible. Read more
fn windowed_sifft(self, window: &WindowFunction<f32>) -> VecResult<Self::RealTimePartner>
Performs a Symmetric Inverse Fast Fourier Transformation (SIFFT) and removes the FFT window. The SIFFT is performed under the assumption that self
contains half of a symmetric spectrum starting from 0 Hz. This assumption isn't verified and no error is raised if the spectrum isn't symmetric. The reason for this is that there is no robust verification possible. Read more
impl FrequencyDomainOperations<f64> for ComplexFreqVector<f64>
[src]
type ComplexTimePartner = ComplexTimeVector<f64>
fn plain_ifft(self) -> VecResult<ComplexTimeVector<f64>>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector. Read more
fn mirror(self) -> VecResult<ComplexFreqVector<f64>>
This function mirrors the spectrum vector to transform a symmetric spectrum into a full spectrum with the DC element at index 0 (no fft shift/swap halves). Read more
fn ifft(self) -> VecResult<Self::ComplexTimePartner>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector. # Example Read more
fn windowed_ifft(self, window: &WindowFunction<f64>) -> VecResult<Self::ComplexTimePartner>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector and removes the FFT window. Read more
fn fft_shift(self) -> VecResult<Self>
Swaps vector halves after a Fourier Transformation.
fn ifft_shift(self) -> VecResult<Self>
Swaps vector halves before an Inverse Fourier Transformation.
impl SymmetricFrequencyDomainOperations<f64> for ComplexFreqVector<f64>
[src]
type RealTimePartner = RealTimeVector<f64>
fn plain_sifft(self) -> VecResult<Self::RealTimePartner>
Performs a Symmetric Inverse Fast Fourier Transformation under the assumption that self
contains half of a symmetric spectrum starting from 0 Hz. This assumption isn't verified and no error is raised if the spectrum isn't symmetric. The reason for this is that there is no robust verification possible. Read more
fn sifft(self) -> VecResult<Self::RealTimePartner>
Performs a Symmetric Inverse Fast Fourier Transformation under the assumption that self
contains half of a symmetric spectrum starting from 0 Hz. This assumption isn't verified and no error is raised if the spectrum isn't symmetric. The reason for this is that there is no robust verification possible. Read more
fn windowed_sifft(self, window: &WindowFunction<f64>) -> VecResult<Self::RealTimePartner>
Performs a Symmetric Inverse Fast Fourier Transformation (SIFFT) and removes the FFT window. The SIFFT is performed under the assumption that self
contains half of a symmetric spectrum starting from 0 Hz. This assumption isn't verified and no error is raised if the spectrum isn't symmetric. The reason for this is that there is no robust verification possible. Read more
impl<'a> FrequencyMultiplication<f32, &'a ComplexFrequencyResponse<f32>> for ComplexFreqVector<f32>
[src]
fn multiply_frequency_response(self, function: &ComplexFrequencyResponse<f32>, ratio: f32) -> VecResult<Self>
Mutiplies self
with the frequency response function frequency_response
. Read more
impl<'a> FrequencyMultiplication<f32, &'a RealFrequencyResponse<f32>> for ComplexFreqVector<f32>
[src]
fn multiply_frequency_response(self, function: &RealFrequencyResponse<f32>, ratio: f32) -> VecResult<Self>
Mutiplies self
with the frequency response function frequency_response
. Read more
impl<'a> FrequencyMultiplication<f64, &'a ComplexFrequencyResponse<f64>> for ComplexFreqVector<f64>
[src]
fn multiply_frequency_response(self, function: &ComplexFrequencyResponse<f64>, ratio: f64) -> VecResult<Self>
Mutiplies self
with the frequency response function frequency_response
. Read more
impl<'a> FrequencyMultiplication<f64, &'a RealFrequencyResponse<f64>> for ComplexFreqVector<f64>
[src]
fn multiply_frequency_response(self, function: &RealFrequencyResponse<f64>, ratio: f64) -> VecResult<Self>
Mutiplies self
with the frequency response function frequency_response
. Read more
impl VectorConvolution<f32> for ComplexFreqVector<f32>
[src]
fn convolve_vector(self, other: &Self) -> VecResult<Self>
Convolves self
with the convolution function impulse_response
. For performance it's recommended to use multiply both vectors in frequency domain instead of this operation. # Failures VecResult may report the following ErrorReason
members: Read more
impl VectorConvolution<f64> for ComplexFreqVector<f64>
[src]
fn convolve_vector(self, other: &Self) -> VecResult<Self>
Convolves self
with the convolution function impulse_response
. For performance it's recommended to use multiply both vectors in frequency domain instead of this operation. # Failures VecResult may report the following ErrorReason
members: Read more
impl Interpolation<f32> for ComplexFreqVector<f32>
[src]
fn interpolatef(self, function: &RealImpulseResponse<f32>, interpolation_factor: f32, delay: f32, len: usize) -> VecResult<Self>
Interpolates self
with the convolution function function
by the real value interpolation_factor
. Interpolation is done in 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()
. Read more
fn interpolatei(self, function: &RealFrequencyResponse<f32>, interpolation_factor: u32) -> VecResult<Self>
Interpolates self
with the convolution function function
by the interger value interpolation_factor
. Interpolation is done in in frequency domain. Read more
fn decimatei(self, decimation_factor: u32, delay: u32) -> VecResult<Self>
Decimates or downsamples self
. decimatei
is the inverse function to interpolatei
.
impl Interpolation<f64> for ComplexFreqVector<f64>
[src]
fn interpolatef(self, function: &RealImpulseResponse<f64>, interpolation_factor: f64, delay: f64, len: usize) -> VecResult<Self>
Interpolates self
with the convolution function function
by the real value interpolation_factor
. Interpolation is done in 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()
. Read more
fn interpolatei(self, function: &RealFrequencyResponse<f64>, interpolation_factor: u32) -> VecResult<Self>
Interpolates self
with the convolution function function
by the interger value interpolation_factor
. Interpolation is done in in frequency domain. Read more
fn decimatei(self, decimation_factor: u32, delay: u32) -> VecResult<Self>
Decimates or downsamples self
. decimatei
is the inverse function to interpolatei
.
impl<T: Debug> Debug for ComplexFreqVector<T> where T: RealNumber
[src]
impl<T> DataVector<T> for ComplexFreqVector<T> where T: RealNumber
[src]
fn len(&self) -> usize
The number of valid elements in the the vector.
fn set_len(&mut self, len: usize)
Sets the vector length to the given length. If self.len() < len
then the value of the new elements is undefined. Read more
fn allocated_len(&self) -> usize
Gets the number of allocated elements in the underlying vector. The allocated length may be larger than the length of valid points. In most cases you likely want to have len
or points
instead. Read more
fn data(&self) -> &[T]
Gives direct access to the underlying data sequence. It's recommended to use the `Index functions . For users outside of Rust: It's discouraged to hold references to this array while executing operations on the vector, since the vector may decide at any operation to invalidate the array. Read more
fn delta(&self) -> T
The x-axis delta. If domain
is time domain then delta
is in [s]
, in frequency domain delta
is in [Hz]
.
fn domain(&self) -> DataVectorDomain
The domain in which the data vector resides. Basically specifies the x-axis and the type of operations which are valid on this vector. Read more
fn is_complex(&self) -> bool
Indicates whether the vector contains complex data. This also specifies the type of operations which are valid on this vector. Read more
fn points(&self) -> usize
The number of valid points. If the vector is complex then every valid point consists of two floating point numbers, while for real vectors every point only consists of one floating point number. Read more
impl<T> RededicateVector<T> for ComplexFreqVector<T> where T: RealNumber
[src]
fn rededicate_as_complex_time_vector(self, delta: T) -> ComplexTimeVector<T>
Make self
a complex time vector # Example Read more
fn rededicate_as_complex_freq_vector(self, delta: T) -> ComplexFreqVector<T>
Make self
a complex frequency vector
fn rededicate_as_real_time_vector(self, delta: T) -> RealTimeVector<T>
Make self
a real time vector
fn rededicate_as_real_freq_vector(self, delta: T) -> RealFreqVector<T>
Make self
a real freq vector
fn rededicate_as_generic_vector(self, is_complex: bool, domain: DataVectorDomain, delta: T) -> GenericDataVector<T>
Make self
a generic vector
impl<T> Index<usize> for ComplexFreqVector<T> where T: RealNumber
[src]
type Output = T
The returned type after indexing
fn index(&self, index: usize) -> &T
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<usize> for ComplexFreqVector<T> where T: RealNumber
[src]
impl<T> Index<Range<usize>> for ComplexFreqVector<T> where T: RealNumber
[src]
type Output = [T]
The returned type after indexing
fn index(&self, index: Range<usize>) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<Range<usize>> for ComplexFreqVector<T> where T: RealNumber
[src]
fn index_mut(&mut self, index: Range<usize>) -> &mut [T]
The method for the indexing (Foo[Bar]
) operation
impl<T> Index<RangeFrom<usize>> for ComplexFreqVector<T> where T: RealNumber
[src]
type Output = [T]
The returned type after indexing
fn index(&self, index: RangeFrom<usize>) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<RangeFrom<usize>> for ComplexFreqVector<T> where T: RealNumber
[src]
fn index_mut(&mut self, index: RangeFrom<usize>) -> &mut [T]
The method for the indexing (Foo[Bar]
) operation
impl<T> Index<RangeTo<usize>> for ComplexFreqVector<T> where T: RealNumber
[src]
type Output = [T]
The returned type after indexing
fn index(&self, index: RangeTo<usize>) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<RangeTo<usize>> for ComplexFreqVector<T> where T: RealNumber
[src]
fn index_mut(&mut self, index: RangeTo<usize>) -> &mut [T]
The method for the indexing (Foo[Bar]
) operation
impl<T> Index<RangeFull> for ComplexFreqVector<T> where T: RealNumber
[src]
type Output = [T]
The returned type after indexing
fn index(&self, index: RangeFull) -> &[T]
The method for the indexing (Foo[Bar]
) operation
impl<T> IndexMut<RangeFull> for ComplexFreqVector<T> where T: RealNumber
[src]
fn index_mut(&mut self, index: RangeFull) -> &mut [T]
The method for the indexing (Foo[Bar]
) operation
impl<T> Clone for ComplexFreqVector<T> where T: RealNumber
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl GenericVectorOperations<f32> for ComplexFreqVector<f32>
[src]
fn add_vector(self, summand: &Self) -> VecResult<Self>
Calculates the sum of self + summand
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn add_smaller_vector(self, summand: &Self) -> VecResult<Self>
Calculates the sum of self + summand
. summand
may be smaller than self
as long as self.len() % summand.len() == 0
. THe result is the same as it would be if you would repeat summand
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn subtract_vector(self, subtrahend: &Self) -> VecResult<Self>
Calculates the difference of self - subtrahend
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn subtract_smaller_vector(self, subtrahend: &Self) -> VecResult<Self>
Calculates the sum of self - subtrahend
. subtrahend
may be smaller than self
as long as self.len() % subtrahend.len() == 0
. THe result is the same as it would be if you would repeat subtrahend
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn multiply_vector(self, factor: &Self) -> VecResult<Self>
Calculates the product of self * factor
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn multiply_smaller_vector(self, factor: &Self) -> VecResult<Self>
Calculates the sum of self - factor
. factor
may be smaller than self
as long as self.len() % factor.len() == 0
. THe result is the same as it would be if you would repeat factor
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn divide_vector(self, divisor: &Self) -> VecResult<Self>
Calculates the quotient of self / summand
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn divide_smaller_vector(self, divisor: &Self) -> VecResult<Self>
Calculates the sum of self - divisor
. divisor
may be smaller than self
as long as self.len() % divisor.len() == 0
. THe result is the same as it would be if you would repeat divisor
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn zero_pad(self, points: usize, option: PaddingOption) -> VecResult<Self>
Appends zeros add the end of the vector until the vector has the size given in the points argument. If points
smaller than the self.len()
then this operation won't do anything. Read more
fn reverse(self) -> VecResult<Self>
Reverses the data inside the vector.
fn zero_interleave(self, factor: u32) -> VecResult<Self>
Ineterleaves zeros factor - 1
times after every vector element, so that the resulting vector will have a length of self.len() * factor
. Read more
fn diff(self) -> VecResult<Self>
Calculates the delta of each elements to its previous element. This will decrease the vector length by one point. Read more
fn diff_with_start(self) -> VecResult<Self>
Calculates the delta of each elements to its previous element. The first element will remain unchanged. Read more
fn cum_sum(self) -> VecResult<Self>
Calculates the cumulative sum of all elements. This operation undoes the diff_with_start
operation. Read more
fn sqrt(self) -> VecResult<Self>
Gets the square root of all vector elements. Read more
fn square(self) -> VecResult<Self>
Squares all vector elements. Read more
fn root(self, degree: f32) -> VecResult<Self>
Calculates the n-th root of every vector element. Read more
fn power(self, exponent: f32) -> VecResult<Self>
Raises every vector element to the given power. Read more
fn logn(self) -> VecResult<Self>
Calculates the natural logarithm to the base e for every vector element. Read more
fn expn(self) -> VecResult<Self>
Calculates the natural exponential to the base e for every vector element. Read more
fn log_base(self, base: f32) -> VecResult<Self>
Calculates the logarithm to the given base for every vector element. Read more
fn sin(self) -> VecResult<Self>
Calculates the sine of each element in radians. Read more
fn cos(self) -> VecResult<Self>
Calculates the cosine of each element in radians. Read more
fn tan(self) -> VecResult<Self>
Calculates the tangent of each element in radians.
fn asin(self) -> VecResult<Self>
Calculates the principal value of the inverse sine of each element in radians.
fn acos(self) -> VecResult<Self>
Calculates the principal value of the inverse cosine of each element in radians.
fn atan(self) -> VecResult<Self>
Calculates the principal value of the inverse tangent of each element in radians.
fn sinh(self) -> VecResult<Self>
Calculates the hyperbolic sine each element in radians.
fn cosh(self) -> VecResult<Self>
Calculates the hyperbolic cosine each element in radians.
fn tanh(self) -> VecResult<Self>
Calculates the hyperbolic tangent each element in radians.
fn asinh(self) -> VecResult<Self>
Calculates the principal value of the inverse hyperbolic sine of each element in radians.
fn acosh(self) -> VecResult<Self>
Calculates the principal value of the inverse hyperbolic cosine of each element in radians.
fn atanh(self) -> VecResult<Self>
Calculates the principal value of the inverse hyperbolic tangent of each element in radians.
fn swap_halves(self) -> VecResult<Self>
This function swaps both halves of the vector. This operation is also called fft shift Use it after a plain_fft
to get a spectrum which is centered at 0 Hz
. Read more
fn exp_base(self, base: f32) -> VecResult<Self>
Calculates the exponential to the given base for every vector element. Read more
fn override_data(self, data: &[f32]) -> VecResult<Self>
Overrides the data in the vector with the given data. This may also change the vectors length (however not the allocated length). Read more
fn split_into(&self, targets: &mut [Box<Self>]) -> VoidResult
Splits the vector into several smaller vectors. self.len()
must be dividable by targets.len()
without a remainder and this conidition must be true too targets.len() > 0
. # Failures VecResult may report the following ErrorReason
members: Read more
fn merge(self, sources: &[Box<Self>]) -> VecResult<Self>
Merges several vectors into self
. All vectors must have the same size and at least one vector must be provided. # Failures VecResult may report the following ErrorReason
members: Read more
impl GenericVectorOperations<f64> for ComplexFreqVector<f64>
[src]
fn add_vector(self, summand: &Self) -> VecResult<Self>
Calculates the sum of self + summand
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn add_smaller_vector(self, summand: &Self) -> VecResult<Self>
Calculates the sum of self + summand
. summand
may be smaller than self
as long as self.len() % summand.len() == 0
. THe result is the same as it would be if you would repeat summand
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn subtract_vector(self, subtrahend: &Self) -> VecResult<Self>
Calculates the difference of self - subtrahend
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn subtract_smaller_vector(self, subtrahend: &Self) -> VecResult<Self>
Calculates the sum of self - subtrahend
. subtrahend
may be smaller than self
as long as self.len() % subtrahend.len() == 0
. THe result is the same as it would be if you would repeat subtrahend
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn multiply_vector(self, factor: &Self) -> VecResult<Self>
Calculates the product of self * factor
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn multiply_smaller_vector(self, factor: &Self) -> VecResult<Self>
Calculates the sum of self - factor
. factor
may be smaller than self
as long as self.len() % factor.len() == 0
. THe result is the same as it would be if you would repeat factor
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn divide_vector(self, divisor: &Self) -> VecResult<Self>
Calculates the quotient of self / summand
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn divide_smaller_vector(self, divisor: &Self) -> VecResult<Self>
Calculates the sum of self - divisor
. divisor
may be smaller than self
as long as self.len() % divisor.len() == 0
. THe result is the same as it would be if you would repeat divisor
until it has the same length as self
. It consumes self and returns the result. # Failures VecResult may report the following ErrorReason
members: Read more
fn zero_pad(self, points: usize, option: PaddingOption) -> VecResult<Self>
Appends zeros add the end of the vector until the vector has the size given in the points argument. If points
smaller than the self.len()
then this operation won't do anything. Read more
fn reverse(self) -> VecResult<Self>
Reverses the data inside the vector.
fn zero_interleave(self, factor: u32) -> VecResult<Self>
Ineterleaves zeros factor - 1
times after every vector element, so that the resulting vector will have a length of self.len() * factor
. Read more
fn diff(self) -> VecResult<Self>
Calculates the delta of each elements to its previous element. This will decrease the vector length by one point. Read more
fn diff_with_start(self) -> VecResult<Self>
Calculates the delta of each elements to its previous element. The first element will remain unchanged. Read more
fn cum_sum(self) -> VecResult<Self>
Calculates the cumulative sum of all elements. This operation undoes the diff_with_start
operation. Read more
fn sqrt(self) -> VecResult<Self>
Gets the square root of all vector elements. Read more
fn square(self) -> VecResult<Self>
Squares all vector elements. Read more
fn root(self, degree: f64) -> VecResult<Self>
Calculates the n-th root of every vector element. Read more
fn power(self, exponent: f64) -> VecResult<Self>
Raises every vector element to the given power. Read more
fn logn(self) -> VecResult<Self>
Calculates the natural logarithm to the base e for every vector element. Read more
fn expn(self) -> VecResult<Self>
Calculates the natural exponential to the base e for every vector element. Read more
fn log_base(self, base: f64) -> VecResult<Self>
Calculates the logarithm to the given base for every vector element. Read more
fn sin(self) -> VecResult<Self>
Calculates the sine of each element in radians. Read more
fn cos(self) -> VecResult<Self>
Calculates the cosine of each element in radians. Read more
fn tan(self) -> VecResult<Self>
Calculates the tangent of each element in radians.
fn asin(self) -> VecResult<Self>
Calculates the principal value of the inverse sine of each element in radians.
fn acos(self) -> VecResult<Self>
Calculates the principal value of the inverse cosine of each element in radians.
fn atan(self) -> VecResult<Self>
Calculates the principal value of the inverse tangent of each element in radians.
fn sinh(self) -> VecResult<Self>
Calculates the hyperbolic sine each element in radians.
fn cosh(self) -> VecResult<Self>
Calculates the hyperbolic cosine each element in radians.
fn tanh(self) -> VecResult<Self>
Calculates the hyperbolic tangent each element in radians.
fn asinh(self) -> VecResult<Self>
Calculates the principal value of the inverse hyperbolic sine of each element in radians.
fn acosh(self) -> VecResult<Self>
Calculates the principal value of the inverse hyperbolic cosine of each element in radians.
fn atanh(self) -> VecResult<Self>
Calculates the principal value of the inverse hyperbolic tangent of each element in radians.
fn swap_halves(self) -> VecResult<Self>
This function swaps both halves of the vector. This operation is also called fft shift Use it after a plain_fft
to get a spectrum which is centered at 0 Hz
. Read more
fn exp_base(self, base: f64) -> VecResult<Self>
Calculates the exponential to the given base for every vector element. Read more
fn override_data(self, data: &[f64]) -> VecResult<Self>
Overrides the data in the vector with the given data. This may also change the vectors length (however not the allocated length). Read more
fn split_into(&self, targets: &mut [Box<Self>]) -> VoidResult
Splits the vector into several smaller vectors. self.len()
must be dividable by targets.len()
without a remainder and this conidition must be true too targets.len() > 0
. # Failures VecResult may report the following ErrorReason
members: Read more
fn merge(self, sources: &[Box<Self>]) -> VecResult<Self>
Merges several vectors into self
. All vectors must have the same size and at least one vector must be provided. # Failures VecResult may report the following ErrorReason
members: Read more
impl ComplexVectorOperations<f32> for ComplexFreqVector<f32>
[src]
type RealPartner = RealTimeVector<f32>
fn complex_data(&self) -> &[Complex<f32>]
Gets self.data()
as complex array.
fn complex_offset(self, offset: Complex<f32>) -> VecResult<Self>
Adds a scalar to the vector. # Example Read more
fn complex_scale(self, factor: Complex<f32>) -> VecResult<Self>
Multiplies the vector with a scalar. # Example Read more
fn multiply_complex_exponential(self, a: f32, b: f32) -> VecResult<Self>
Multiplies each vector element with exp(j*(a*idx*self.delta() + b))
where a
and b
are arguments and idx
is the index of the data points in the vector ranging from 0 to self.points() - 1
. j
is the imaginary number and exp
the exponential function. Read more
fn magnitude(self) -> VecResult<Self::RealPartner>
Gets the absolute value or magnitude of all vector elements. # Example Read more
fn get_magnitude(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies the absolute value or magnitude of all vector elements into the given target vector. # Example Read more
fn magnitude_squared(self) -> VecResult<Self::RealPartner>
Gets the square root of the absolute value of all vector elements. # Example Read more
fn complex_conj(self) -> VecResult<Self>
Calculates the complex conjugate of the vector. # Example Read more
fn to_real(self) -> VecResult<Self::RealPartner>
Gets all real elements. # Example Read more
fn to_imag(self) -> VecResult<Self::RealPartner>
Gets all imag elements. # Example Read more
fn get_real(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies all real elements into the given vector. # Example Read more
fn get_imag(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies all imag elements into the given vector. # Example Read more
fn phase(self) -> VecResult<Self::RealPartner>
Gets the phase of all elements in [rad]. # Example Read more
fn get_phase(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies the phase of all elements in [rad] into the given vector. # Example Read more
fn complex_dot_product(&self, factor: &Self) -> ScalarResult<Complex<f32>>
Calculates the dot product of self and factor. Self and factor remain unchanged. # Failures VecResult may report the following ErrorReason
members: Read more
fn complex_statistics(&self) -> Statistics<Complex<f32>>
Calculates the statistics of the data contained in the vector. # Example Read more
fn complex_statistics_splitted(&self, len: usize) -> Vec<Statistics<Complex<f32>>>
Calculates the statistics of the data contained in the vector as if the vector would have been split into len
pieces. self.len
should be devisable by len
without a remainder, but this isn't enforced by the implementation. # Example Read more
fn get_real_imag(&self, real: &mut Self::RealPartner, imag: &mut Self::RealPartner) -> VoidResult
Gets the real and imaginary parts and stores them in the given vectors. See get_phase
and get_complex_abs
for further information. Read more
fn get_mag_phase(&self, mag: &mut Self::RealPartner, phase: &mut Self::RealPartner) -> VoidResult
Gets the magnitude and phase and stores them in the given vectors. See get_real
and get_imag
for further information. Read more
fn set_real_imag(self, real: &Self::RealPartner, imag: &Self::RealPartner) -> VecResult<Self>
Overrides the self
vectors data with the real and imaginary data in the given vectors. real
and imag
must have the same size. Read more
fn set_mag_phase(self, mag: &Self::RealPartner, phase: &Self::RealPartner) -> VecResult<Self>
Overrides the self
vectors data with the magnitude and phase data in the given vectors. Note that self
vector will immediately convert the data into a real and imaginary representation of the complex numbers which is its default format. mag
and phase
must have the same size. Read more
impl Scale<Complex<f32>> for ComplexFreqVector<f32>
[src]
fn scale(self, offset: Complex<f32>) -> VecResult<Self>
Multiplies the vector element with a scalar.
impl Offset<Complex<f32>> for ComplexFreqVector<f32>
[src]
impl ComplexVectorOperations<f64> for ComplexFreqVector<f64>
[src]
type RealPartner = RealTimeVector<f64>
fn complex_data(&self) -> &[Complex<f64>]
Gets self.data()
as complex array.
fn complex_offset(self, offset: Complex<f64>) -> VecResult<Self>
Adds a scalar to the vector. # Example Read more
fn complex_scale(self, factor: Complex<f64>) -> VecResult<Self>
Multiplies the vector with a scalar. # Example Read more
fn multiply_complex_exponential(self, a: f64, b: f64) -> VecResult<Self>
Multiplies each vector element with exp(j*(a*idx*self.delta() + b))
where a
and b
are arguments and idx
is the index of the data points in the vector ranging from 0 to self.points() - 1
. j
is the imaginary number and exp
the exponential function. Read more
fn magnitude(self) -> VecResult<Self::RealPartner>
Gets the absolute value or magnitude of all vector elements. # Example Read more
fn get_magnitude(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies the absolute value or magnitude of all vector elements into the given target vector. # Example Read more
fn magnitude_squared(self) -> VecResult<Self::RealPartner>
Gets the square root of the absolute value of all vector elements. # Example Read more
fn complex_conj(self) -> VecResult<Self>
Calculates the complex conjugate of the vector. # Example Read more
fn to_real(self) -> VecResult<Self::RealPartner>
Gets all real elements. # Example Read more
fn to_imag(self) -> VecResult<Self::RealPartner>
Gets all imag elements. # Example Read more
fn get_real(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies all real elements into the given vector. # Example Read more
fn get_imag(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies all imag elements into the given vector. # Example Read more
fn phase(self) -> VecResult<Self::RealPartner>
Gets the phase of all elements in [rad]. # Example Read more
fn get_phase(&self, destination: &mut Self::RealPartner) -> VoidResult
Copies the phase of all elements in [rad] into the given vector. # Example Read more
fn complex_dot_product(&self, factor: &Self) -> ScalarResult<Complex<f64>>
Calculates the dot product of self and factor. Self and factor remain unchanged. # Failures VecResult may report the following ErrorReason
members: Read more
fn complex_statistics(&self) -> Statistics<Complex<f64>>
Calculates the statistics of the data contained in the vector. # Example Read more
fn complex_statistics_splitted(&self, len: usize) -> Vec<Statistics<Complex<f64>>>
Calculates the statistics of the data contained in the vector as if the vector would have been split into len
pieces. self.len
should be devisable by len
without a remainder, but this isn't enforced by the implementation. # Example Read more
fn get_real_imag(&self, real: &mut Self::RealPartner, imag: &mut Self::RealPartner) -> VoidResult
Gets the real and imaginary parts and stores them in the given vectors. See get_phase
and get_complex_abs
for further information. Read more
fn get_mag_phase(&self, mag: &mut Self::RealPartner, phase: &mut Self::RealPartner) -> VoidResult
Gets the magnitude and phase and stores them in the given vectors. See get_real
and get_imag
for further information. Read more
fn set_real_imag(self, real: &Self::RealPartner, imag: &Self::RealPartner) -> VecResult<Self>
Overrides the self
vectors data with the real and imaginary data in the given vectors. real
and imag
must have the same size. Read more
fn set_mag_phase(self, mag: &Self::RealPartner, phase: &Self::RealPartner) -> VecResult<Self>
Overrides the self
vectors data with the magnitude and phase data in the given vectors. Note that self
vector will immediately convert the data into a real and imaginary representation of the complex numbers which is its default format. mag
and phase
must have the same size. Read more
impl Scale<Complex<f64>> for ComplexFreqVector<f64>
[src]
fn scale(self, offset: Complex<f64>) -> VecResult<Self>
Multiplies the vector element with a scalar.