Crate basic_dsp_vector [] [src]

Basic digital signal processing (DSP) operations

Digital signal processing based on real or complex vectors in time or frequency domain. Vectors are expected to typically have a size which is at least in the order of magnitude of a couple of thousand elements. This crate tries to balance between a clear API and performance in terms of processing speed. This project started as small pet project to learn more about DSP, CPU architecture and Rust. Since learning involves making mistakes, don't expect things to be flawless or even close to flawless.

This library isn't suited - from my point of view - for game programming. If you are looking for vector types to do 2D or 3D graphics calculations then you unfortunately have to continue with your search. However there seem to be a lot of suitable crates on crates.io for you.

The vector types don't distinguish between 1xN or Nx1. This is a difference to other conventions such as in MATLAB or GNU Octave. The reason for this decision is that it seems to be more practical to ignore the shape of the vector.

Right now the library uses pretty aggressive parallelization. So this means that it will keep all CPU cores busy even if the performance gain is minimal e.g. because the multi core overhead is nearly as large as the performance boost of multiple cores. In future there will be likely an option which tells the library how it should balance between processing time and CPU utilization. The library also avoids to allocate and free memory so it allocates all of the required temporary memory when a new vector is constructed. Therefore the library is likely not suitable for devices which are tight on memory. On normal desktop computers there is usually plenty of memory available so that the optimization focus is on decreasing the processing time for every (common) operation and to spent little time with memory allocations.

Modules

combined_ops
conv_types

Types around a convolution, see also https://en.wikipedia.org/wiki/Convolution.

window_functions

This mod contains a definition for window functions and provides implementations for a few standard windows. See the WindowFunction type for more information.

Structs

ComplexData

Marker for types containing complex data.

DspVec

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.

FrequencyData

Marker for types containing frequency data.

MultiCoreSettings

Holds parameters which specify how multiple cores are used to execute an operation.

RealData

Marker for types containing real data.

RealOrComplexData

Marker for types containing real or complex data.

SingleBuffer

A buffer which stores a single vector and never shrinks.

Statistics

Statistics about numeric data

TimeData

Marker for types containing time data.

TimeOrFrequencyData

Marker for types containing time or frequency data.

Enums

DataDomain

The domain of a data vector

ErrorReason

Enumeration of all error reasons

PaddingOption

An option which defines how a vector should be padded

Traits

Buffer

A buffer which can be used by other types. Types will call buffers to create new arrays. A buffer may can implement any buffering strategy.

ComplexIndex

Like std::ops::Index but with a different method name so that it can be used to implement an additional range accessor for complex data.

ComplexIndexMut

Like std::ops::IndexMut but with a different method name so that it can be used to implement a additional range accessor for complex data.

ComplexNumberSpace

Trait for types containing complex data.

ComplexOps

Operations on complex types.

ComplexToRealGetterOps

Defines getters to get real data from complex types.

ComplexToRealSetterOps

Defines setters to create complex data from real data.

ComplexToRealTransformsOps

Defines transformations from complex to real number space.

ComplexToRealTransformsOpsBuffered

Defines transformations from complex to real number space.

Convolution

Provides a convolution operations.

ConvolutionOps

Provides a convolution operation for types which at some point are slice based.

CrossCorrelationArgumentOps

Cross-correlation of data vectors. See also https://en.wikipedia.org/wiki/Cross-correlation

CrossCorrelationOps
DiffSumOps
Domain

Domain (time or frequency) information.

DotProductOps

An operation which multiplies each vector element with a constant

ElementaryOps
ElementaryWrapAroundOps
FrequencyDomain

Trait for types containing frequency domain data.

FrequencyDomainOperations

Defines all operations which are valid on DataVecs containing frequency domain data.

FrequencyMultiplication

Provides a frequency response multiplication operations.

FrequencyToTimeDomainOperations

Defines all operations which are valid on DataVecs containing frequency domain data.

FromVector

Retrieves the underlying storage from a vector.

InsertZerosOps
InsertZerosOpsBuffered
InterleaveToVector

Conversion from two instances of a generic data type into a dsp vector with complex data.

InterpolationOps

Provides interpolation operations for real and complex data vectors.

MapAggregateOps
MapInplaceNoArgsOps

Operations which allow to iterate over the vector and to derive results or to change the vector.

MapInplaceOps

Operations which allow to iterate over the vector and to derive results or to change the vector.

MergeOps
MetaData

A trait which provides information about number space and domain.

ModuloOps

Operations on real types.

NumberSpace

Number space (real or complex) information.

OffsetOps

An operation which adds a constant to each vector element

Owner

A marker trait which states the the type owns its storage.

PowerOps

Roots, powers, exponentials and logarithms.

PreciseDotProductOps

An operation which multiplies each vector element with a constant

PreciseStatisticsOps
PreciseStats
PreciseSumOps
RealInterpolationOps

Provides interpolation operations which are only applicable for real data vectors.

RealNumber

A real floating pointer number intended to abstract over f32 and f64.

RealNumberSpace

Trait for types containing real data.

RealOps

Operations on real types.

RealToComplexTransformsOps

Defines transformations from real to complex number space.

RealToComplexTransformsOpsBuffered

Defines transformations from real to complex number space.

RededicateForceOps

This trait allows to change a data type and performs the Conversion without any checks. RededicateOps provides the same functionality but performs runtime checks to avoid that data is interpreted the wrong way.

RededicateOps

This trait allows to change a data type. The operations will convert a type to a different one and set self.len() to zero. However self.allocated_len() will remain unchanged. The use case for this is to allow to reuse the memory of a vector for different operations.

RededicateToOps

This trait allows to change a data type. The operations will convert a type to a different one and set self.len() to zero. However self.allocated_len() will remain unchanged. The use case for this is to allow to reuse the memory of a vector for different operations.

ReorganizeDataOps
ReorganizeDataOpsBuffered [Deprecated]
Resize

A trait for storage types which are known to have the capability to increase their capacity.

ResizeOps

Operations to resize a data type.

ScaleOps

An operation which multiplies each vector element with a constant

SplitOps
StatisticsOps
Stats
SumOps
SymmetricFrequencyToTimeDomainOperations

Defines all operations which are valid on DataVecs containing frequency domain data and the data is assumed to half of complex conjugate symmetric spectrum round 0 Hz where the 0 Hz element itself is real.

SymmetricTimeToFrequencyDomainOperations

Defines all operations which are valid on DataVecs containing real time domain data.

TimeDomain

Trait for types containing time domain data.

TimeDomainOperations

Defines all operations which are valid on DataVecs containing time domain data.

TimeToFrequencyDomainOperations

Defines all operations which are valid on DataVecs containing time domain data.

ToComplexResult

Specifies what the the result is if a type is transformed to complex numbers.

ToComplexVector

Conversion from a generic data type into a dsp vector with complex data.

ToDspVector

Conversion from a generic data type into a dsp vector which tracks its meta information (domain and number space) only at runtime. See ToRealVector and ToComplexVector for alternatives which track most of the meta data with the type system and therefore avoid runtime errors.

ToFreqResult

Specifies what the the result is if a type is transformed to frequency domain.

ToRealResult

Specifies what the the result is if a type is transformed to real numbers.

ToRealTimeResult

Specifies what the the result is if a type is transformed to real numbers in time domain.

ToRealVector

Conversion from a generic data type into a dsp vector with real data.

ToSimd

Associates a number type with a SIMD register type.

ToSlice

A trait to convert a type into a slice.

ToSliceMut

A trait to convert a type into a mutable slice.

ToTimeResult
TrigOps

Trigonometry methods.

Vector

A trait for vector types.

Type Definitions

ComplexFreqVec

A vector with complex numbers in frequency domain.

ComplexFreqVec32

A vector with complex numbers in frequency domain.

ComplexFreqVec64

A vector with complex numbers in frequency domain.

ComplexFreqVecSlice32

A vector with complex numbers in frequency domain.

ComplexFreqVecSlice64

A vector with complex numbers in frequency domain.

ComplexTimeVec

A vector with complex numbers in time domain.

ComplexTimeVec32

A vector with complex numbers in time domain.

ComplexTimeVec64

A vector with complex numbers in time domain.

ComplexTimeVecSlice32

A vector with complex numbers in time domain.

ComplexTimeVecSlice64

A vector with complex numbers in time domain.

GenDspVec

A vector with no information about number space or domain at compile time.

GenDspVec32

A vector with no information about number space or domain at compile time.

GenDspVec64

A vector with no information about number space or domain at compile time.

GenDspVecSlice32

A vector with no information about number space or domain at compile time.

GenDspVecSlice64

A vector with no information about number space or domain at compile time.

RealFreqVec

A vector with real numbers in frequency domain.

RealFreqVec32

A vector with real numbers in frequency domain.

RealFreqVec64

A vector with real numbers in frequency domain.

RealFreqVecSlice32

A vector with real numbers in frequency domain.

RealFreqVecSlice64

A vector with real numbers in frequency domain.

RealTimeVec

A vector with real numbers in time domain.

RealTimeVec32

A vector with real numbers in time domain.

RealTimeVec64

A vector with real numbers in time domain.

RealTimeVecSlice32

A vector with real numbers in time domain.

RealTimeVecSlice64

A vector with real numbers in time domain.

ScalarResult

Scalar result or a reason in case of an error.

TransRes

Result for operations which transform a type (most commonly the type is a vector). On success the transformed type is returned. On failure it contains an error reason and the original type with with invalid data which still can be used in order to avoid memory allocation.

VoidResult

Void/nothing in case of success or a reason in case of an error.