NAG Library Function Document
nag_sum_convcorr_real (c06fkc)
1
Purpose
nag_sum_convcorr_real (c06fkc) calculates the circular convolution or correlation of two real vectors of period .
2
Specification
#include <nag.h> |
#include <nagc06.h> |
void |
nag_sum_convcorr_real (Nag_VectorOp job,
double x[],
double y[],
Integer n,
NagError *fail) |
|
3
Description
nag_sum_convcorr_real (c06fkc) 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 (c06pac) to compute discrete Fourier transforms.
4
References
Brigham E O (1974) The Fast Fourier Transform Prentice–Hall
5
Arguments
- 1:
– Nag_VectorOpInput
-
On entry: the computation to be performed.
- ;
- .
Constraint:
or .
- 2:
– doubleInput/Output
-
On entry: the elements of one period of the vector .
must contain , for .
On exit: the corresponding elements of the discrete convolution or correlation.
- 3:
– doubleInput/Output
-
On entry: the elements of one period of the vector .
must contain , for .
On exit: 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
Section 2.1.2 in the c06 Chapter Introduction.)
- 4:
– IntegerInput
-
On entry:
, the number of values in one period of the vectors
x and
y.
Constraint:
.
- 5:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.7 in How to Use the NAG Library and its Documentation).
6
Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
is an invalid value of
job.
- NE_INT
-
On entry, .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
See
Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
The results should be accurate to within a small multiple of the machine precision.
8
Parallelism and Performance
nag_sum_convcorr_real (c06fkc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_sum_convcorr_real (c06fkc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The time taken is approximately proportional to , but also depends on the factorization of . nag_sum_convcorr_real (c06fkc) is faster if the only prime factors of are , or ; and fastest of all if is a power of .
10
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 (c06fkc)). In realistic computations the number of data values would be much larger.
10.1
Program Text
Program Text (c06fkce.c)
10.2
Program Data
Program Data (c06fkce.d)
10.3
Program Results
Program Results (c06fkce.r)