PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sum_withdraw_convcorr_real_nowork (c06ek)
Purpose
nag_sum_convcorr_real_nowork (c06ek) calculates the circular convolution or correlation of two real vectors of period . (No extra workspace is required.)
Note: this function is scheduled to be withdrawn, please see
c06ek in
Advice on Replacement Calls for Withdrawn/Superseded Routines..
Syntax
[
x,
y,
ifail] = nag_sum_withdraw_convcorr_real_nowork(
job,
x,
y, 'n',
n)
Description
nag_sum_convcorr_real_nowork (c06ek) 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_real_1d_nowork (c06ea) and
nag_sum_fft_hermitian_1d_nowork (c06eb) to compute discrete Fourier transforms, and there are some restrictions on the value of
.
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_nowork (c06ek) 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_nowork (c06ek) 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:
where
and
when
is even then
holds
and
holds nonzero
(see
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:
-
-
At least one of the prime factors of
n is greater than
.
-
-
n has more than
prime factors.
-
-
-
-
-
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_nowork (c06ek) is faster if the only prime factors of are , or ; and fastest of all if is a power of .
On the other hand,
nag_sum_convcorr_real_nowork (c06ek) is particularly slow if
has several unpaired prime factors, i.e., if the ‘square-free’ part of
has several factors.
For such values of
,
nag_sum_convcorr_real (c06fk) (which requires additional double workspace) is considerably faster.
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_nowork (c06ek)). In realistic computations the number of data values would be much larger.
Open in the MATLAB editor:
c06ek_example
function c06ek_example
fprintf('c06ek 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] = c06ek(job, x, y);
job = int64(2);
[corr, tcorr, ifail] = c06ek(job, x, y);
result = [conv corr];
disp('Convolution Correlation');
disp(result);
c06ek 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