VF_autocorrVD_autocorrVE_autocorr
VFb_autocorrVDb_autocorrVEb_autocorr
Functionautocorrelation function
Syntax C/C++#include <VFstd.h>
void VF_autocorr( fVector Y, fVector X, ui size );
void VFb_autocorr( fVector Y, fVector X, ui size, fVector Buf );
C++ VecObj#include <OptiVec.h>
void vector<float>::autocorr( const vector<float>& X );
void vector<float>::b_autocorr( const vector<float>& X, vector<float>& Buf );
Pascal/Delphiuses VFstd;
procedure VF_autocorr( Y, X:fVector; size:UIntSize );
procedure VFb_autocorr( Y, X:fVector; size:UIntSize; Buf:fVector );
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_autocorr( fVector d_Y, fVector d_X, ui size );
void VFcu_autocorr( fVector h_Y, fVector h_X, ui size );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_autocorr( d_Y, d_X:fVector; size:UIntSize ): IntBool;
procedure VFcu_autocorr( h_Y, h_X:fVector; size:UIntSize );
DescriptionThe autocorrelation function (ACF) of X is calculated and stored in Y in wrap-around order: Y0 to Ysize/2−1 contain the ACF for zero and positive lags. Beginning with the most negative lag in Ysize/2+1, the elements up to Ysize−1 contain the ACF for negative lags. Since this function assumes X to be periodic, the ACF for the most positive lag is identical to the ACF for the most negative lag. This element is stored as Ysize/2.
To get the ACF into normal order, you may call
VF_rotate( Y, Y, size, size/2 );
After that, the zero point is at the position size/2.

In case X is non-periodic, you should avoid end effects by the methods described in connection with VF_convolve.

Internally, VF_autocorr allocates and frees additional workspace memory. For repeated calls, this would be inefficient. In such a case, it is recommended to use VFb_autocorr instead. The size of Buf must be ≥ size. Additionally, Buf must be 128-bit (P8) or 256-bit (P9) aligned. This usually means you can only take a vector allocated by the VF_vector family as Buf.

Error handlingIf size is not a power of 2, VF_FFT (on which VF_autocorr is based) complains "Size must be an integer power of 2" and the program is aborted.
Return valuenone
See alsoVF_FFT,   VF_convolve,   VF_xcorr,   VF_spectrum

VectorLib Table of Contents  OptiVec home