MF_autocorr MD_autocorr ME_autocorr
MFb_autocorr MDb_autocorr MEb_autocorr
FunctionSpatial autocorrelation function
Syntax C/C++#include <MFstd.h>
void MF_autocorr( fMatrix Y, fMatrix X, ui ht, ui len ); void MFb_autocorr( fMatrix Y, fMatrix X, ui ht, ui len, fVector Buf );
C++ MatObj#include <OptiVec.h>
void matrix<T>::autocorr( const matrix<T>& MX); void matrix<T>::b_autocorr( const matrix<T>& MX, vector<T>& Buf);
Pascal/Delphiuses MFstd;
procedure MF_autocorr( MY, MX:fMatrix; ht, len:UIntSize ); procedure MFb_autocorr( MY, MX:fMatrix; ht, len:UIntSize; Buf:fVector );
CUDA function C/C++#include <cudaMFstd.h>
int cudaMF_autocorr( fMatrix d_Y, fMatrix d_X, ui ht, ui len );
void MFcu_autocorr( fMatrix h_Y, fMatrix h_X, ui ht, ui len );
CUDA function Pascal/Delphiuses MFstd;
function cudaMF_autocorr( d_MY, d_MX:fMatrix; ht, len:UIntSize ): IntBool;
procedure MFcu_autocorr( h_MY, h_MX:fMatrix; ht, len:UIntSize );
DescriptionThe spatial autocorrelation function (SACF) of MX is calculated and stored in MY in wrap-around order in both dimensions: The row elements MYi,0 to MYi,len/2-1 contain the SACF for zero and positive x lags. Beginning with the most negative lag in MYi,len/2+1, the elements up to MYi,len-1 contain the SACF for negative lags. Since this function assumes MX to be periodic, the SACF for the most positive lag is identical to the SACF for the most negative lag. This element is stored as Yi,len/2.
Similarly, the column elements MY0,j to MYlen/2-1,j contain the SACF for zero and positive y lags. Beginning with the most negative lag in MYlen/2+1,j, the elements up to MYlen-1,j contain the SACF for negative lags.
To get the SACF into normal order, you may call
MF_Rows_rotate( MY, ht, len, len/2 );
MF_Cols_rotate( MY, ht, len, ht/2 );

After that, the zero point is at the position MYht/2,len/2.
In case MX is non-periodic, you should avoid end effects by the methods described in connection with MF_convolve.
Both ht and len must be integer powers of 2.

Internally, MF_autocorr allocates and frees additional workspace memory. For repeated calls, this would be inefficient. In such a case, it is recommended to use MFb_autocorr instead. For C/C++, the size of Buf must be >= ht*(len+2), for Pascal/Delphi, it must be >= ht*len. 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 either len or ht is not a power of 2, VF_FFT (on which MF_autocorr is based) complains "Size must be an integer power of 2" and the program is aborted.
See alsoMF_FFT,   MF_convolve,   VF_autocorr,   chapter 12

MatrixLib Table of Contents  OptiVec home