NMSISDSP
Version 1.2.0
NMSIS DSP Software Library

►Basic Math Functions  
Vector Absolute Value  Computes the absolute value of a vector on an elementbyelement basis 
Vector Addition  Elementbyelement addition of two vectors 
Vector bitwise AND  Compute the logical bitwise AND 
Elementwise clipping  Elementbyelement clipping of a value 
Vector Dot Product  Computes the dot product of two vectors. The vectors are multiplied elementbyelement and then summed 
Vector Multiplication  Elementbyelement multiplication of two vectors 
Vector Negate  Negates the elements of a vector 
Vector bitwise NOT  Compute the logical bitwise NOT 
Vector Offset  Adds a constant offset to each element of a vector 
Vector bitwise inclusive OR  Compute the logical bitwise OR 
Vector Scale  Multiply a vector by a scalar value. For floatingpoint data, the algorithm used is: 
Vector Shift  Shifts the elements of a fixedpoint vector by a specified number of bits. There are separate functions for Q7, Q15, and Q31 data types. The underlying algorithm used is: 
Vector Subtraction  Elementbyelement subtraction of two vectors 
Vector bitwise exclusive OR  Compute the logical bitwise XOR 
Bayesian estimators  Implement the naive gaussian Bayes estimator. The training must be done from scikitlearn 
►Complex Math Functions  This set of functions operates on complex data vectors. The data in the complex arrays is stored in an interleaved fashion (real, imag, real, imag, ...). In the API functions, the number of samples in a complex array refers to the number of complex values; the array contains twice this number of real values 
Complex Conjugate  Conjugates the elements of a complex data vector 
Complex Dot Product  Computes the dot product of two complex vectors. The vectors are multiplied elementbyelement and then summed 
Complex Magnitude  Computes the magnitude of the elements of a complex data vector 
Complex Magnitude Squared  Computes the magnitude squared of the elements of a complex data vector 
ComplexbyComplex Multiplication  Multiplies a complex vector by another complex vector and generates a complex result. The data in the complex arrays is stored in an interleaved fashion (real, imag, real, imag, ...). The parameter numSamples represents the number of complex samples processed. The complex arrays have a total of 2*numSamples real values 
ComplexbyReal Multiplication  Multiplies a complex vector by a real vector and generates a complex result. The data in the complex arrays is stored in an interleaved fashion (real, imag, real, imag, ...). The parameter numSamples represents the number of complex samples processed. The complex arrays have a total of 2*numSamples real values while the real array has a total of numSamples real values 
►Controller Functions  
Sine Cosine  Computes the trigonometric sine and cosine values using a combination of table lookup and linear interpolation. There are separate functions for Q31 and floatingpoint data types. The input to the floatingpoint version is in degrees while the fixedpoint Q31 have a scaled input with the range [1 0.9999] mapping to [180 +180] degrees 
PID Motor Control  A Proportional Integral Derivative (PID) controller is a generic feedback control loop mechanism widely used in industrial control systems. A PID controller is the most commonly used type of feedback controller 
Vector Park Transform  Forward Park transform converts the input twocoordinate vector to flux and torque components. The Park transform can be used to realize the transformation of the Ialpha and the Ibeta currents from the stationary to the moving reference frame and control the spatial relationship between the stator vector current and rotor flux vector. If we consider the d axis aligned with the rotor flux, the diagram below shows the current vector and the relationship from the two reference frames: 
Vector Inverse Park transform  Inverse Park transform converts the input flux and torque components to twocoordinate vector 
Vector Clarke Transform  Forward Clarke transform converts the instantaneous stator phases into a twocoordinate time invariant vector. Generally the Clarke transform uses threephase currents Ia, Ib and Ic to calculate currents in the twophase orthogonal stator axis Ialpha and Ibeta . When Ialpha is superposed with Ia as shown in the figure below 
Vector Inverse Clarke Transform  Inverse Clarke transform converts the twocoordinate time invariant vector into instantaneous stator phases 
►Distance functions  Distance functions for use with clustering algorithms. There are distance functions for float vectors and boolean vectors 
►Float Distances  Distances between two vectors of float values 
BrayCurtis distance  BrayCurtis distance between two vectors 
Canberra distance  Canberra distance 
Chebyshev distance  Chebyshev distance 
Cityblock (Manhattan) distance  Cityblock (Manhattan) distance 
Correlation distance  Correlation distance 
Cosine distance  Cosine distance 
Dynamic Time Warping Distance  Dynamic Time Warping Distance 
Euclidean distance  Euclidean distance 
JensenShannon distance  JensenShannon distance 
Minkowski distance  Minkowski distance 
Boolean Distances  Distances between two vectors of boolean values 
►Fast Math Functions  This set of functions provides a fast approximation to sine, cosine, and square root. As compared to most of the other functions in the NMSIS math library, the fast math functions operate on individual values and not arrays. There are separate functions for Q15, Q31, and floatingpoint data 
ArcTan2  Computing Arc tangent only using the ratio y/x is not enough to determine the angle since there is an indeterminacy. Opposite quadrants are giving the same ratio 
Cosine  Computes the trigonometric cosine function using a combination of table lookup and linear interpolation. There are separate functions for Q15, Q31, and floatingpoint data types. The input to the floatingpoint version is in radians while the fixedpoint Q15 and Q31 have a scaled input with the range [0 +0.9999] mapping to [0 2*pi). The fixedpoint range is chosen so that a value of 2*pi wraps around to 0 
Fixed point division  
Sine  Computes the trigonometric sine function using a combination of table lookup and linear interpolation. There are separate functions for Q15, Q31, and floatingpoint data types. The input to the floatingpoint version is in radians while the fixedpoint Q15 and Q31 have a scaled input with the range [0 +0.9999] mapping to [0 2*pi). The fixedpoint range is chosen so that a value of 2*pi wraps around to 0 
Vector Exponential  Compute the exp values of a vector of samples 
Vector Log  Compute the log values of a vector of samples 
Square Root  Computes the square root of a number. There are separate functions for Q15, Q31, and floatingpoint data types. The square root function is computed using the NewtonRaphson algorithm. This is an iterative algorithm of the form: 
►Filtering Functions  
High Precision Q31 Biquad Cascade Filter  This function implements a high precision Biquad cascade filter which operates on Q31 data values. The filter coefficients are in 1.31 format and the state variables are in 1.63 format. The double precision state variables reduce quantization noise in the filter and provide a cleaner output. These filters are particularly useful when implementing filters in which the singularities are close to the unit circle. This is common for low pass or high pass filters with very low cutoff frequencies 
Biquad Cascade IIR Filters Using Direct Form I Structure  This set of functions implements arbitrary order recursive (IIR) filters. The filters are implemented as a cascade of second order Biquad sections. The functions support Q15, Q31 and floatingpoint data types. Fast version of Q15 and Q31 also available 
Biquad Cascade IIR Filters Using a Direct Form II Transposed Structure  This set of functions implements arbitrary order recursive (IIR) filters using a transposed direct form II structure. The filters are implemented as a cascade of second order Biquad sections. These functions provide a slight memory savings as compared to the direct form I Biquad filter functions. Only floatingpoint data is supported 
Convolution  Convolution is a mathematical operation that operates on two finite length vectors to generate a finite length output vector. Convolution is similar to correlation and is frequently used in filtering and data analysis. The NMSIS DSP library contains functions for convolving Q7, Q15, Q31, and floatingpoint data types. The library also provides fast versions of the Q15 and Q31 functions 
Partial Convolution  Partial Convolution is equivalent to Convolution except that a subset of the output samples is generated. Each function has two additional arguments. firstIndex specifies the starting index of the subset of output samples. numPoints is the number of output samples to compute. The function computes the output in the range [firstIndex, ..., firstIndex+numPoints1] . The output array pDst contains numPoints values 
Correlation  Correlation is a mathematical operation that is similar to convolution. As with convolution, correlation uses two signals to produce a third signal. The underlying algorithms in correlation and convolution are identical except that one of the inputs is flipped in convolution. Correlation is commonly used to measure the similarity between two signals. It has applications in pattern recognition, cryptanalysis, and searching. The NMSIS library provides correlation functions for Q7, Q15, Q31 and floatingpoint data types. Fast versions of the Q15 and Q31 functions are also provided 
Finite Impulse Response (FIR) Decimator  These functions combine an FIR filter together with a decimator. They are used in multirate systems for reducing the sample rate of a signal without introducing aliasing distortion. Conceptually, the functions are equivalent to the block diagram below: 
Finite Impulse Response (FIR) Filters  This set of functions implements Finite Impulse Response (FIR) filters for Q7, Q15, Q31, and floatingpoint data types. Fast versions of Q15 and Q31 are also provided. The functions operate on blocks of input and output data and each call to the function processes blockSize samples through the filter. pSrc and pDst points to input and output arrays containing blockSize values 
Finite Impulse Response (FIR) Lattice Filters  
Finite Impulse Response (FIR) Sparse Filters  
Infinite Impulse Response (IIR) Lattice Filters  This set of functions implements lattice filters for Q15, Q31 and floatingpoint data types. Lattice filters are used in a variety of adaptive filter applications. The filter structure has feedforward and feedback components and the net impulse response is infinite length. The functions operate on blocks of input and output data and each call to the function processes blockSize samples through the filter. pSrc and pDst point to input and output arrays containing blockSize values 
Levinson Durbin Algorithm  
Least Mean Square (LMS) Filters  LMS filters are a class of adaptive filters that are able to "learn" an unknown transfer functions. LMS filters use a gradient descent method in which the filter coefficients are updated based on the instantaneous error signal. Adaptive filters are often used in communication systems, equalizers, and noise removal. The NMSIS DSP Library contains LMS filter functions that operate on Q15, Q31, and floatingpoint data types. The library also contains normalized LMS filters in which the filter coefficient adaptation is indepedent of the level of the input signal 
Normalized LMS Filters  This set of functions implements a commonly used adaptive filter. It is related to the Least Mean Square (LMS) adaptive filter and includes an additional normalization factor which increases the adaptation rate of the filter. The NMSIS DSP Library contains normalized LMS filter functions that operate on Q15, Q31, and floatingpoint data types 
Finite Impulse Response (FIR) Interpolator  These functions combine an upsampler (zero stuffer) and an FIR filter. They are used in multirate systems for increasing the sample rate of a signal without introducing high frequency images. Conceptually, the functions are equivalent to the block diagram below: 
►Interpolation Functions  These functions perform 1 and 2dimensional interpolation of data. Linear interpolation is used for 1dimensional data and bilinear interpolation is used for 2dimensional data 
Bilinear Interpolation  Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid. The underlying function f(x, y) is sampled on a regular grid and the interpolation process determines values between the grid points. Bilinear interpolation is equivalent to two step linear interpolation, first in the xdimension and then in the ydimension. Bilinear interpolation is often used in image processing to rescale images. The NMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floatingpoint data types 
Linear Interpolation  Linear interpolation is a method of curve fitting using linear polynomials. Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line 
Cubic Spline Interpolation  Spline interpolation is a method of interpolation where the interpolant is a piecewisedefined polynomial called "spline" 
►Matrix Functions  This set of functions provides basic matrix math operations. The functions operate on matrix data structures. For example, the type definition for the floatingpoint matrix structure is shown below: 
Householder transform of a vector  Computes the Householder transform of a vector x 
Matrix Addition  Adds two matrices 
Cholesky and LDLT decompositions  Computes the Cholesky or LL^t decomposition of a matrix 
Complex Matrix Multiplication  Complex Matrix multiplication is only defined if the number of columns of the first matrix equals the number of rows of the second matrix. Multiplying an M x N matrix with an N x P matrix results in an M x P matrix 
Complex Matrix Transpose  Tranposes a complex matrix 
Matrix Initialization  Initializes the underlying matrix data structure. The functions set the numRows , numCols , and pData fields of the matrix data structure 
Matrix Inverse  Computes the inverse of a matrix 
Matrix Multiplication  Multiplies two matrices 
QR decomposition of a Matrix  Computes the QR decomposition of a matrix M using Householder algorithm 
Matrix Scale  Multiplies a matrix by a scalar. This is accomplished by multiplying each element in the matrix by the scalar. For example: 
Matrix Subtraction  Subtract two matrices 
Matrix Transpose  Tranposes a matrix 
Matrix Vector Multiplication  Multiplies a matrix and a vector 
►Quaternion Math Functions  Functions to operates on quaternions and convert between a rotation and quaternion representation 
►Quaternion conversions  Conversions between quaternion and rotation representations 
Quaternion to Rotation  Conversions from quaternion to rotation 
Rotation to Quaternion  Conversions from rotation to quaternion 
Quaternion Conjugate  Compute the conjugate of a quaternion 
Quaternion Inverse  Compute the inverse of a quaternion 
Quaternion Norm  Compute the norm of a quaternion 
Quaternion normalization  Compute a normalized quaternion 
►Quaternion Product  Compute the product of quaternions 
Elementwise Quaternion Product  Compute the elementwise product of quaternions 
Quaternion Product  Compute the product of two quaternions 
►Statistics Functions  
Absolute Maximum  Computes the maximum value of absolute values of an array of data. The function returns both the maximum value and its position within the array. There are separate functions for floatingpoint, Q31, Q15, and Q7 data types 
Absolute Minimum  Computes the minimum value of absolute values of an array of data. The function returns both the minimum value and its position within the array. There are separate functions for floatingpoint, Q31, Q15, and Q7 data types 
Accumulation functions  Calculates the accumulation of the input vector. Sum is defined as the addition of the elements in the vector. The underlying algorithm is used: 
Entropy  Computes the entropy of a distribution 
KullbackLeibler divergence  Computes the KullbackLeibler divergence between two distributions 
LogSumExp  LogSumExp optimizations to compute sum of probabilities with Gaussian distributions 
Maximum  Computes the maximum value of an array of data. The function returns both the maximum value and its position within the array. There are separate functions for floatingpoint, Q31, Q15, and Q7 data types 
Mean  Calculates the mean of the input vector. Mean is defined as the average of the elements in the vector. The underlying algorithm is used: 
Minimum  Computes the minimum value of an array of data. The function returns both the minimum value and its position within the array. There are separate functions for floatingpoint, Q31, Q15, and Q7 data types 
Mean Square Error  Calculates the mean square error between two vectors 
Power  Calculates the sum of the squares of the elements in the input vector. The underlying algorithm is used: 
Root mean square (RMS)  Calculates the Root Mean Square of the elements in the input vector. The underlying algorithm is used: 
Standard deviation  Calculates the standard deviation of the elements in the input vector 
Variance  Calculates the variance of the elements in the input vector. The underlying algorithm used is the direct method sometimes referred to as the twopass method: 
►Support Functions  
Typecasting  
Barycenter  Barycenter of weighted vectors 
Vector sorting algorithms  Sort the elements of a vector 
Vector Copy  Copies sample by sample from source vector to destination vector 
Convert 16bit floating point value  
Convert 64bit floating point value  
Vector Fill  Fills the destination vector with a constant value 
Convert 32bit floating point value  
Convert 16bit fixed point value  
Convert 32bit fixed point value  
Convert 8bit fixed point value  
Weighted Sum  Weighted sum of values 
►SVM Functions  This set of functions is implementing SVM classification on 2 classes. The training must be done from scikitlearn. The parameters can be easily generated from the scikitlearn object. Some examples are given in DSP/Testing/PatternGeneration/SVM.py 
Linear SVM  Linear SVM classifier 
Polynomial SVM  Polynomial SVM classifier 
RBF SVM  RBF SVM classifier 
Sigmoid SVM  Sigmoid SVM classifier 
►Transform Functions  
►Complex FFT Functions  
Complex FFT Tables  
Complex FFT F16  
Complex FFT F32  
Complex FFT F64  
Complex FFT Q15  
Complex FFT Q31  
Deprecated Complex FFT functions  
►DCT Type IV Functions  Representation of signals by minimum number of values is important for storage and transmission. The possibility of large discontinuity between the beginning and end of a period of a signal in DFT can be avoided by extending the signal so that it is evensymmetric. Discrete Cosine Transform (DCT) is constructed such that its energy is heavily concentrated in the lower part of the spectrum and is very widely used in signal and image coding applications. The family of DCTs (DCT type 1,2,3,4) is the outcome of different combinations of homogeneous boundary conditions. DCT has an excellent energypacking capability, hence has many applications and in data compression in particular 
DCT Type IV Tables  
DCT4 F32  
DCT4 Q15  
DCT4 Q31  
►MFCC  MFCC Transform 
MFCC F32  
MFCC F16  
MFCC Q15  
MFCC Q31  
►Real FFT Functions  
Real FFT F16 Functions  
Real FFT F64 Functions  
Real FFT Q15 Functions  
Real FFT Q31 Functions  
Real FFT Tables  
Real FFT F32 Functions  
Deprecated Real FFT Functions  
►Window Functions  
►Flattop window functions  Use those windows when you need to estimate the amplitude of a tone 
Hft116d window function (116.8 dB)  
Hft144d window function (144.1 dB)  
Hft169d window function (169.5 dB)  
Hft196d window function (196.2 dB)  
Hft223d window function (223.0 dB)  
Hft248d window function (248.4 dB)  
Hft90d window function (90.2 dB)  
Hft95 window function (95.0 dB)  
►Regular window functions  Regular window functions that can be used for detecting tones or estimating the noise. If you need to estimate the amplitude of a tones, prefer a flat top window 
Bartlett window function (26.5 dB)  
Blackman Harris window function (92 dB)  
Hamming window function (42.7 dB)  
Hanning window function (31.5 dB)  
Nuttall3 window function (46.7 dB)  
Nuttall3a window function (64.2 dB)  
Nuttall3b window function (71.5 dB)  
Nuttall4 window function (60.9 dB)  
Nuttall4a window function (82.6 dB)  
Nuttall4b window function (93.3 dB)  
Nuttall4c window function (98.1 dB)  
Welch window function (21.3 dB)  
►Examples  
Bayes Example  
Class Marks Example  
Convolution Example  
Dot Product Example  
Frequency Bin Example  
FIR Lowpass Filter Example  
Graphic Audio Equalizer Example  
Linear Interpolate Example  NMSIS DSP Software Library – Linear Interpolate Example 
Matrix Example  
Signal Convergence Example  
SineCosine Example  
SVM Example  
Variance Example 