MF_autocorr MD_autocorr ME_autocorr
FunctionSpatial autocorrelation function
Syntax C/C++#include <MFstd.h>
void MF_autocorr( fMatrix Y, fMatrix X, ui ht, ui len );
C++ MatObj#include <OptiVec.h>
void matrix<T>::autocorr( const matrix<T>& MX);
Pascal/Delphiuses MFstd;
procedure MF_autocorr( MY, 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.
About special versions with the prefixes MFl_ and MFs_, consult chapter 4.8 of http://www.optivec.com/vecfuncs/.
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