IBM Books

Engineering and Scientific Subroutine Library for AIX Version 3 Release 3: Guide and Reference

SACORF--Autocorrelation of One or More Sequences Using the Mixed-Radix Fourier Method

This subroutine computes the autocorrelations of one or more sequences using the mixed-radix Fourier method. The input and output sequences contain short-precision real numbers.

Note:
Two invocations of this subroutine are necessary: one to prepare the working storage for the subroutine, and the other to perform the computations.

Syntax

Fortran CALL SACORF (init, x, inc1x, inc2x, y, inc1y, inc2y, nx, m, ny, aux1, naux1, aux2, naux2)
C and C++ sacorf (init, x, inc1x, inc2x, y, inc1y, inc2y, nx, m, ny, aux1, naux1, aux2, naux2);
PL/I CALL SACORF (init, x, inc1x, inc2x, y, inc1y, inc2y, nx, m, ny, aux1, naux1, aux2, naux2);

On Entry

init
is a flag, where:

If init <> 0, trigonometric functions and other parameters, depending on arguments other than x, are computed and saved in aux1. The contents of x and y are not used or changed.

If init = 0, the autocorrelations of the sequence in x are computed. The only arguments that may change after initialization are x, y, and aux2. All scalar arguments must be the same as when the subroutine was called for initialization with init <> 0.

Specified as: a fullword integer. It can have any value.

x
is the array X, consisting of m input sequences of length Nx, to be autocorrelated. Specified as: an array of (at least) length 1+(Nx-1)inc1x+(m-1)inc2x, containing short-precision real numbers.

inc1x
is the stride between the elements within each sequence in array X. Specified as: a fullword integer; inc1x > 0.

inc2x
is the stride between the first elements of the sequences in array X. Specified as: a fullword integer; inc2x > 0.

y
See On Return.

inc1y
is the stride between the elements within each sequence in output array Y. Specified as: a fullword integer; inc1y > 0.

inc2y
is the stride between the first elements of each sequence in output array Y. Specified as: a fullword integer; inc2y > 0.

nx
is the number of elements, Nx, in each sequence in array X. Specified as: a fullword integer; Nx > 0.

m
is the number of sequences in array X to be correlated. Specified as: a fullword integer; m > 0.

ny
is the number of elements, Ny, in each sequence in array Y. Specified as: a fullword integer; Ny > 0.

aux1
is the working storage for this subroutine, where:

If init <> 0, the working storage is computed.

If init = 0, the working storage is used in the computation of the autocorrelations.

Specified as: an area of storage, containing naux1 long-precision real numbers.

naux1
is the number of doublewords in the working storage specified in aux1. Specified as: a fullword integer; naux1 > 21 and naux1 >= (minimum value required for successful processing). To determine a sufficient value, use the processor-independent formulas. For values between 21 and the minimum value, you have the option of having the minimum value returned in this argument. For details, see Using Auxiliary Storage in ESSL.

aux2
has the following meaning:

If naux2 = 0 and error 2015 is unrecoverable, aux2 is ignored.

Otherwise, it is the working storage used by this subroutine, which is available for use by the calling program between calls to this subroutine.

Specified as: an area of storage, containing naux2 long-precision real numbers. On output, the contents are overwritten.

naux2
is the number of doublewords in the working storage specified in aux2. Specified as: a fullword integer, where:

If naux2 = 0 and error 2015 is unrecoverable, SACORF dynamically allocates the work area used by this subroutine. The work area is deallocated before control is returned to the calling program.

Otherwise, naux2 >= (minimum value required for successful processing). To determine a sufficient value, use the processor-independent formulas. For all other values specified less than the minimum value, you have the option of having the minimum value returned in this argument. For details, see Using Auxiliary Storage in ESSL.

On Return

y
has the following meaning, where:

If init <> 0, this argument is not used, and its contents remain unchanged.

If init = 0, this is array Y, consisting of m output sequences of length Ny that are the autocorrelation functions of the sequences in array X.

Returned as: an array of (at least) length 1+(Ny-1)inc1y+(m-1)inc2y, containing short-precision real numbers.

aux1
is the working storage for this subroutine, where:

If init <> 0, it contains information ready to be passed in a subsequent invocation of this subroutine.

If init = 0, its contents are unchanged.

Returned as: the contents are not relevant.

Notes
  1. aux1 should not be used by the calling program between calls to this subroutine with init <> 0 and init = 0. However, it can be reused after intervening calls to this subroutine with different arguments.
  2. When using the ESSL SMP library, for optimal performance, the number of threads specified should be the same for init <> 0 and init = 0.
  3. If you specify the same array for X and Y, then inc1x and inc1y must be equal and inc2x and inc2y must be equal. In this case, output overwrites input.
  4. If you specify different arrays for X and Y, they must have no common elements; otherwise, results are unpredictable. See Concepts.
  5. If ny is such that output outside the basic range is needed, the subroutine stores zeros. This range is: 0 <= k <= nx-1.

Formula for Calculating the Length of the Fourier Transform

Before calculating the necessary sizes of naux1 and naux2, you must determine the length n of the Fourier transform. To do this, you use the values of the arguments nx and ny, inserted into the following formula, to get a value for the variable nf. After calculating nf, reference the formula or table of allowable values of n in Acceptable Lengths for the Transforms, selecting the value equal to or greater than nf. Following is the formula for determining nf:

nf = min(ny, nx)+nx+1

Processor-Independent Formulas for NAUX1 and NAUX2

The required values of naux1 and naux2 depend on the value determined for n in Formula for Calculating the Length of the Fourier Transform and the argument m.

NAUX1 Formulas
If n <= 16384, use naux1 = 55000.
If n > 16384, use naux1 = 40000+1.89n.

NAUX2 Formulas
If n <= 16384, use naux2 = 50000.
If n > 16384, use naux2 = 40000+1.64n.

Function

The autocorrelations of the sequences in array X are expressed as follows:



Autocorrelations of the Sequences Graphic

for:

k = 0, 1, ..., Ny-1
i = 1, 2, ..., m

where:

yki are elements of the m sequences of length Ny in array Y.
xji and xj+k,i are elements of the m sequences of length Nx in array X.

This subroutine uses a Fourier transform method with a mixed-radix capability. This provides maximum performance for your application. The length of the transform, n, that you must calculate to determine the correct sizes for naux1 and naux2 is the same length used by the Fourier transform subroutines called by this subroutine. See references [17] and [84].

Two invocations of this subroutine are necessary:

  1. With init <> 0, the subroutine tests and initializes arguments of the program, setting up the aux1 working storage.
  2. With init = 0, the subroutine checks that the initialization arguments in the aux1 working storage correspond to the present arguments, and if so, performs the calculation of the autocorrelations.

Error Conditions

Resource Errors

Error 2015 is unrecoverable, naux2 = 0, and unable to allocate work area.

Computational Errors

None

Input-Argument Errors
  1. nx, ny, or m <= 0
  2. inc1x, inc2x, inc1y, or inc2y <= 0 (or incompatible)
  3. The resulting correlation is too long.
  4. The subroutine has not been initialized with the present arguments.
  5. naux1 <= 21
  6. naux1 is too small--that is, less than the minimum required value. Return code 1 is returned if error 2015 is recoverable.
  7. Error 2015 is recoverable or naux2<>0, and naux2 is too small--that is, less than the minimum required value. Return code 1 is returned if error 2015 is recoverable.

Example 1

This example shows how to compute an autocorrelation for three short sequences in array X, where the input sequence length NX is equal to the output sequence length NY. This gives all nonzero autocorrelation values. The arrays are declared as follows:

     REAL*4   X(0:49999), Y(0:49999)
     REAL*8   AUX1(30788), AUX2(17105)

First, initialize AUX1 using the calling sequence shown below with INIT <> 0. Then use the same calling sequence with INIT = 0 to do the calculation.

Call Statement and Input


            INIT  X INC1X INC2X Y INC1Y INC2Y NX  M   NY  AUX1  NAUX1 AUX2  NAUX2
             |    |   |     |   |   |     |   |   |   |    |      |    |      |
CALL SACORF(INIT, X , 1  ,  7 , Y , 1  ,  7 , 7 , 3 , 7 , AUX1, 2959, AUX2, 4354)

INIT = 1(for initialization)
INIT = 0(for computation)

X contains the following three sequences:

1.0  2.0  3.0
2.0  1.0  2.0
3.0  2.0  1.0
4.0  3.0  2.0
4.0  4.0  3.0
3.0  4.0  4.0
2.0  3.0  4.0

Output

Y contains the following three sequences:

59.0  59.0  59.0
54.0  50.0  44.0
43.0  39.0  30.0
29.0  27.0  24.0
16.0  18.0  21.0
 7.0  11.0  20.0
 2.0   6.0  12.0

Example 2

This example shows how the output from Example 1 differs when the value for NY and INC2Y are 9 rather than 7. This shows that when NY is greater than NX, the output array is longer and that part is filled with zeros.

Output

Y contains the following three sequences:

59.0  59.0  59.0
54.0  50.0  44.0
43.0  39.0  30.0
29.0  27.0  24.0
16.0  18.0  21.0
 7.0  11.0  20.0
 2.0   6.0  12.0
 0.0   0.0   0.0
 0.0   0.0   0.0

Example 3

This example shows how the output from Example 1 differs when the value for NY is 5 rather than 7. Also, the values for INC1X and INC1Y are 3 rather than 1, and the values for INC2X and INC2Y are 1 rather than 7. This shows that when NY is less than NX, the output array is shortened.

Output

Y contains the following three sequences:

59.0  59.0  59.0
54.0  50.0  44.0
43.0  39.0  30.0
29.0  27.0  24.0
16.0  18.0  21.0


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]