ConvolveEx
- Updated2023-02-21
- 4 minute(s) read
Advanced Analysis Library Only
AnalysisLibErrType ConvolveEx (double arrayX[], ssize_t sizeOfX, double arrayY[], ssize_t sizeOfY, int algorithm, double outputArray[]);
Purpose
Finds the convolution of the input arrays. National Instruments recommends that you use this function instead of Convolve. ConvolveEx includes an additional parameter, algorithm, which makes it more versatile than Convolve. The linear convolution of the signals x(t) and y(t) is defined as follows:
where the symbol * denotes linear convolution.
When algorithm is ALGORITHM_CONCOR_DIRECT, this function uses the following equation to perform the discrete implementation of the linear convolution and obtain the elements of arrayX * arrayY.
for i = 0, 1, 2, ..., M+N–2
where h is arrayX * arrayY
N is the number of elements in arrayX
M is the number of elements in arrayY
the indexed elements outside the ranges of arrayX and arrayY are equal to zero, as shown in the following relationships:
xj = 0, j < 0, or j ≥ N
and
yj = 0, j < 0, or j ≥ M
![]() |
Note This formula description assumes that M ≤ N. For M > N, exchange (x, y) and (M, N) in the previous equations. |
-
First, this function pads the end of arrayX and arrayY with zeros to make their lengths M + N – 1, as shown in the following equations.
-
Second, this function calculates the Fourier transform of arrayX' and arrayY' according to the following equations.
arrayX'(f) = FFT(x')
arrayY'(f) = FFT(y') -
Third, this function multiplies arrayX'(f) by arrayY'(f) and calculates the inverse Fourier transform of the product. The result is the linear convolution of arrayX and arrayY, as shown in the following equation.
arrayX * arrayY = IFFT(arrayX'(f) ⋅ arrayY'(f))
Thus, this function computes the linear convolution, not the circular convolution. However, because x(t) * y(t)n ↔ X(f)Y(f) is a Fourier transform pair, where x(t) * y(t)n is the circular convolution of x(t) and y(t), you can create a circular version of the convolution.
![]() |
Note This function temporarily allocates memory for use as a work area. If ConvolveEx cannot allocate memory, the function returns an error code. |
Parameters
Input | |||||||||||
Name | Type | Description | |||||||||
arrayX | double [] | First input array. | |||||||||
sizeOfX | ssize_t | Number of elements in arrayX. | |||||||||
arrayY | double [] | Second input array. | |||||||||
sizeOfY | ssize_t | Number of elements in arrayY. | |||||||||
algorithm | int | Specifies the convolution method to use. algorithm must be one of the following values. Note that slight numerical differences can exist between the two methods.
|
|||||||||
Output | |||||||||||
Name | Type | Description | |||||||||
outputArray | double [] | Convolution array. This array must be at least (N + M – 1) elements long. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 9.0 and later