PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sum_convcorr_real (c06fk)
Purpose
nag_sum_convcorr_real (c06fk) calculates the circular convolution or correlation of two real vectors of period (using a work array for extra speed).
Syntax
Description
nag_sum_convcorr_real (c06fk) computes:
- if , the discrete convolution of and , defined by
- if , the discrete correlation of and defined by
Here and are real vectors, assumed to be periodic, with period , i.e., ; and are then also periodic with period .
Note: this usage of the terms ‘convolution’ and ‘correlation’ is taken from
Brigham (1974). The term ‘convolution’ is sometimes used to denote both these computations.
If
,
,
and
are the discrete Fourier transforms of these sequences, i.e.,
then
and
(the bar denoting complex conjugate).
This function calls the same auxiliary functions as
nag_sum_fft_realherm_1d (c06pa) to compute discrete Fourier transforms.
References
Brigham E O (1974) The Fast Fourier Transform Prentice–Hall
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
The computation to be performed.
- (convolution);
- (correlation).
Constraint:
or .
- 2:
– double array
-
The elements of one period of the vector
. If
x is declared with bounds
in the function from which
nag_sum_convcorr_real (c06fk) is called, then
must contain
, for
.
- 3:
– double array
-
The elements of one period of the vector
. If
y is declared with bounds
in the function from which
nag_sum_convcorr_real (c06fk) is called, then
must contain
, for
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
x,
y. (An error is raised if these dimensions are not equal.)
, the number of values in one period of the vectors
x and
y.
Constraint:
.
Output Parameters
- 1:
– double array
-
The corresponding elements of the discrete convolution or correlation.
- 2:
– double array
-
The discrete Fourier transform of the convolution or correlation returned in the array
x; the transform is stored in Hermitian form; if the components of the transform
are written as
, then for
,
is contained in
, and for
,
is contained in
. (See also
Real transforms in the C06 Chapter Introduction.)
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
-
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The results should be accurate to within a small multiple of the
machine precision.
Further Comments
The time taken is approximately proportional to , but also depends on the factorization of . nag_sum_convcorr_real (c06fk) is faster if the only prime factors of are , or ; and fastest of all if is a power of .
Example
This example reads in the elements of one period of two real vectors and , and prints their discrete convolution and correlation (as computed by nag_sum_convcorr_real (c06fk)). In realistic computations the number of data values would be much larger.
Open in the MATLAB editor:
c06fk_example
function c06fk_example
fprintf('c06fk example results\n\n');
x = [1; 1; 1; 1; 1; 0; 0; 0; 0];
y = [0.5; 0.5; 0.5; 0.5; 0; 0; 0; 0; 0];
job = int64(1);
[conv, tconv, ifail] = c06fk(job, x, y);
job = int64(2);
[corr, tcorr, ifail] = c06fk(job, x, y);
result = [conv corr];
disp('Convolution Correlation');
disp(result);
c06fk example results
Convolution Correlation
0.5000 2.0000
1.0000 1.5000
1.5000 1.0000
2.0000 0.5000
2.0000 0.0000
1.5000 0.5000
1.0000 1.0000
0.5000 1.5000
0.0000 2.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015