Convolve
Advanced Analysis Library Only
AnalysisLibErrType Convolve (double arrayX[], ssize_t sizeOfX, double arrayY[], ssize_t sizeOfY, double outputArray[]);
Purpose
![]() |
Note This function has been superseded by ConvolveEx. ConvolveEx includes an additional parameter, which makes it more versatile than Convolve. |
Finds the convolution of the input arrays. Convolve obtains the convolution using the following formula:

where | a = 0, b = i for 0 ≤ i < m |
a = i – m + 1, b = i for m ≤ i < n | |
a = i – m + 1, b = n – 1 for n ≤ i ≤ n + m – 1 |
![]() |
Note This formula description assumes that m ≤ n. For m > n, exchange (x, y) and (m, n) in the previous equations. |
![]() |
Note This function temporarily allocates memory for use as a work area. If Convolve cannot allocate memory, the function returns an error code. |
Example Code
/* Generate two arrays with random numbers and find their convolution. */
double x[256], y[256], cxy[512];
int n, m;
n = 256;
m = 256;
Uniform (n, 17, x);
Uniform (m, 17, y);
Convolve (x, n, y, m, cxy);
Parameters
Input | ||
Name | Type | Description |
arrayX | double [] | First input array. |
sizeOfX | ssize_t | Number of elements in YArray. |
arrayY | double [] | Second input array. |
sizeOfY | ssize_t | Number of elements in XArray. numberXElements must be less than or equal to numberYElements. |
Output | ||
Name | Type | Description |
outputArray | double [] | Convolution array. The size of this array must be at least (numberYElements – numberXElements + 1) elements long. This algorithm executes more efficiently if the sizes of the input arrays are a power of two. |
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 3.1 and later
Example
Refer to analysis\convolve.cws for an example of using the Convolve function.