NMSISDSP
Version 1.0.1
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 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 Offset  Adds a constant offset to each element of a vector 
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 
▼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 
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: 
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 
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 
▼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 
▼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  This set of functions implements Finite Impulse Response (FIR) lattice filters for Q15, Q31 and floatingpoint data types. Lattice filters are used in a variety of adaptive filter applications. The filter structure is feedforward and the net impulse response is finite 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 
Finite Impulse Response (FIR) Sparse Filters  This group of functions implements sparse FIR filters. Sparse FIR filters are equivalent to standard FIR filters except that most of the coefficients are equal to zero. Sparse filters are used for simulating reflections in communications and audio applications 
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 
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: 
▼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: 
Matrix Addition  Adds two matrices 
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 
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 
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 
▼Transform Functions  
▼Complex FFT Functions  
▼Complex FFT Tables  
DCT Type IV Tables  
▼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  
▼Real FFT Functions  
Real FFT Tables  
▼Controller Functions  
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 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 
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 
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 
▼Statistics Functions  
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 
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. The underlying algorithm is used: 
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  
Vector Copy  Copies sample by sample from source vector to destination vector 
Vector Fill  Fills the destination vector with a constant value 
Convert 32bit floating point value  
Convert 16bit Integer value  
Convert 32bit Integer value  
Convert 8bit Integer value  
▼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 
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 
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 
▼Examples  
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  
Variance Example 